I want to select rows that the values do not start with some str. For example, I have a pandas df, and I want to select data do not start with t, a
df
t
You can use str.startswith and negate it.
str.startswith
df[~df['col'].str.startswith('t') & ~df['col'].str.startswith('c')] col 1 mext1 3 okl1
Or the better option, with multiple characters in a tuple as per @Ted Petrou:
df[~df['col'].str.startswith(('t','c'))] col 1 mext1 3 okl1