Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果它有一些字符串或值,Pandas 中是否有类似 grep 的内置函数来删除一行?提前致谢。
看看 df['column_label].str 下面的示例将删除 A 列包含“a”字符且“B”等于 20 的所有行。
In [46]: df Out[46]: A B 0 foo 10 1 bar 20 2 baz 30 In [47]: cond = df['A'].str.contains('a') & (df['B'] == 20) In [48]: df.drop(df[cond].index.values) Out[48]: A B 0 foo 10 2 baz 30