I was new to python and lately I'm having trouble dealing with pandas. It always pops warnings like this: "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 df["第一题"][index] = df["第一题"][index] + 1"
And my code is: enter image description here
So the results end with code 0, and indeed all value in column "第一题" been added 1, but the warning is still there, so I changed the code to: for index in range(len(df["第一题"])): df.loc[df["第一题"][index]] = df.loc[df["第一题"][index] + 1]
The warning is gone now, but the values didn't change, which means, the values didn't add 1 as the operation commanded. Even when I add df = df.copy(), the problem is still there.
So may I know how do I deal with this? Thank you all for help!:)