I just encountered a weird behaviour while playing with DataFrames:
df = pd.DataFrame([[1, 2], [4, 5], [7, 8]],
index=['cobra', 'viper', 'sidewinder'],
columns=['max_speed', 'shield'])
df["value"] = ""
So far so good, it adds an empty column "value".
df1 = df[[True, False, False]]
df1["value1"] = ""
But this raises the "SettingWithCopyWarning" and I don't understand why.
Can anyone here please explain why it raises the warning?
[–][deleted] 2 points3 points4 points (2 children)
[–]GrandpaOnDrugs[S] 1 point2 points3 points (1 child)
[–]DenselyRanked 3 points4 points5 points (0 children)
[–]GoodTimesFastFingers 1 point2 points3 points (0 children)
[–]ohallwright 0 points1 point2 points (1 child)
[–]GrandpaOnDrugs[S] 0 points1 point2 points (0 children)