I am creating a new column ("nf") in a dataframe which contains the difference of subsecquent lines of the "cf" column.
I use the simple code:
gdf["nf"]=gdf["cf"].diff()
This seems to work fine, but I keep the (apparently popular) SettingWithCopyWarning .
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
I'd happily use loc, but am completely unsure how to do that. I was looking for solutions but could not find any example that used diff().
How do I fix this?