I have a very simple problem. I would like to change a value in a given column of a given row of a pandas data frame. I try to do it in the following way:
df['column3'].loc[this_date] = val
As a result I get the following warning:
SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame
My interpretation of this warning is that by using columns name ('column3'
) and loc
I do not really access (refer to) the desired cell of the data frame. Instead, I create an object which is a copy of the "cell" object and then I try to change the value associated with this "copy-object".
What I do not understand is that it seems to work. In spite on the fact that pandas writes me that I try to modify the copy, I do modify the original data frame.
My question is how to make sure that I am really doing what I would like to do and how to do it in a "correct" way so that the pandas does not complain?