I have the following dataframe:
import pandas as pd
df = pd.DataFrame()
df["L1"] = ["A", "A", "B", "B"]
df["L2"] = [0, 1, 0, 1]
df["V1"] = [1,2,3,4]
df["V2"] = [4,3,2,1]
df = df.set_index(["L1", "L2"])
df
And I'm doing the following operation which raises the warning:
temp = df.loc[("A", slice(None)), :]
temp.loc[:, "V1"] /= 3 # warning
Then I'm using
df.loc[("A", slice(None)), :] = temp
df
and it works fine. How can I avoid the warning from the first operation?