Sep-14-2021, 01:34 PM
Hi all,
Here's a code snippet:
This doesn't work. I get an error saying per_MA is not recognized. I want it to be the name of the new column with list element (a number) substituted for per. What's the best way to do this?
Thanks!
Mark
P.S. I haven't worked out the rest, which is why I just included this portion.
Here's a code snippet:
MA_list = [10,50,100] for per in MA_list: df_per = df.copy() df_per[per_MA] = df_per['Adj Close'].rolling(window=per).mean()What I'm trying to do is create new dataframes named df_10, df_50, and df_100. I want them to be df with an additional column named 10_MA, 50_MA, or 100_MA, respectively. The last line defines the additional column as a moving average.
This doesn't work. I get an error saying per_MA is not recognized. I want it to be the name of the new column with list element (a number) substituted for per. What's the best way to do this?
Thanks!
Mark
P.S. I haven't worked out the rest, which is why I just included this portion.