Jul-04-2020, 06:00 PM
Well, let me ask the question in another way.
is there a way just set the specific cell to be the average of 12 cells?
Thanks.
def macdfuncs(data): # here are theclose=data['Close'] code for EMA short and EMA long close=data['Close'] #EMA short sma_short = close.rolling(12).mean() temp1=close.copy() temp1.iloc[0:12] = sma_short[0:12] ema_short = temp1.ewm(span=12, adjust=False).mean()This code is not efficient.
sma_short = close.rolling(12).mean() temp1=close.copy() temp1.iloc[0:12] = sma_short[0:12]I only need the 12th cell in "ema_short" column to be the average of the first 12 cells in "close" column . and 13th to end in "ema_short" to be EMA.
is there a way just set the specific cell to be the average of 12 cells?
Thanks.