I use the following code to create a new column in a dataframe:
# data is a dataframe object
data.loc[:,'test'] = 5
it comes with the following warning:
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 already use .loc[]
, why is there still a warning? Is there any particular point I'm missing in my code? Thanks!