when running the following code :
import pandas as pd
df = pd.DataFrame({"A": [1,2,3],"B": [2,4,8]})
df2 = df[df["A"] < 3]
df2["C"] = 100
I get 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 See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
but this is exactly the behavior I want ( the real table is very big and I don't want to make copies of it), why do I get a warning ? why is it risky ?
df
A B
0 1 2
1 2 4
2 3 8
df2
A B C
0 1 2 100
1 2 4 100