I run this code:
df=df_LtC
df["rolling"] = df["ln_ret"].rolling(window=2).mean() * 2
After running the function, I want to have df and df_LtC as different dataframes. I have no clue why to df_LtC is added the column 'rolling' becoming exactly the same as df.
df_LtC looks like this:
date variable price ln_ret
0 2000-01-01 low 2.03 NaN
1 2000-01-01 close 2.39 0.16
2 2000-01-02 low 2.33 -0.02
3 2000-01-02 close 2.36 0.01