我有一个数据帧DF如下,我想删除或删除名字是汤姆,我使用下面的代码(python3)行:熊猫据帧:删除所有行根据一列值与Python
df1[~df1['name'].str.contains('tom')]
但有错误:
AttributeError: Cannot access attribute 'str' of 'SeriesGroupBy'
objects, try using the 'apply' method
name age weight
tom 10 40
lucy 15 50
john 20 60
tom 10 40
lucy 15 50
john 20 60
tom 10 40
kate 30 70
tick 40 75
bruce 50 75
请帮我解决这个问题,这只是示例数据,因为真正的数据帧是大尺寸。如果你们有快速的解决方案,请告诉我。提前致谢!
错误是说,'df1'是'SeriesGroupBy'对象,而不是数据帧。显然,列'name','age','weight'的DataFrame不是'df1'。 – unutbu