因此,我有一个包含多个列的数据框架,但真正重要的是称为a和B。 如果列A不包含值X或列B不包含值Y,则必须删除该行
我尝试使用此功能:
def removeRows(df, value):
df.drop(df[ (df['A'] != value) | (df['B'] != value)].index, inplace = True)
return df
But i got this error:
A value is trying to be set on a copy of a slice from a DataFrame
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
我建议您添加一个如何使用
removeRows
的示例,因为它看起来不应该引发此警告。当使用部分数据帧调用
removeRows
时,会引发此警告例如:
将发出此警告。 尝试将代码更改为
相关问题 更多 >
编程相关推荐