简体   繁体   中英

Filter pandas dataframe on columns if contains *

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('*'))]

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('\*'))]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM