Reputation: 2155
I have a pandas dataframe where some column values have a astrix *.
I want to remoeve rows that have this.
I have tries this but its not working
df.loc[~(df['col_name'].str.contains('*'))]
Upvotes: 1
Views: 71
Reputation: 863166
Because *
is special regex character add regex=False
to Series.str.contains
:
df.loc[~(df['col_name'].str.contains('*', regex=False))]
Or escape *
:
df.loc[~(df['col_name'].str.contains('\*'))]
Upvotes: 5