How to select rows that do not start with some str in pandas?

You can use the str accessor to get string functionality. The get method can grab a given index of the string.

df[~df.col.str.get(0).isin(['t', 'c'])]

     col
1  mext1
3   okl1

Looks like you can use startswith as well with a tuple (and not a list) of the values you want to exclude.

df[~df.col.str.startswith(('t', 'c'))]

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)