So, I have a dataframe with several columns, but the ones that really matter are called A and B. If column A does not contains value X or If column B does not contain value Y, that row must be dropped.
I tried using this function:
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