I am new to Python and would like to ask for help using for loops
I have a dataframe of stock codes and prices which I have split using the groupby function into the respective stock codes as per below
grouped = list(dft.groupby(dft.StockCode))
What I'm trying to do is a for loop that iterates over the list of dataframes to create a new variable in each dataframe. For example, I would like to calculate the RSI for each stock code.
for df in grouped:
df['RSI']=ta.RSI(df['Close'],14)
I could do this individually by splitting out each stock code and then calculating it but it would be a very time consuming process and I'm wondering if there is a more elegant solution.
Thanks in advance!