I have a pandas dataframe that I want to transform some columns and assign back the transformation into the existing dtaframe:
df.loc[:,df.columns != 'target'].pct_change(-1)
If I do:
df.loc[:,df.columns != 'target'] = df.loc[:,df.columns != 'target'].pct_change(-1)
I get a warning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
What is the right to way to get back the transformed df ? thanks