我想对数据帧的三列进行计算df.为了做到这一点,我想在三列表中运行资产(加密货币)列表的价格,以便在有足够的数据后计算它们的指数移动平均值.
def calculateAllEMA(self,values_array):
df = pd.DataFrame(values_array, columns=['BTC', 'ETH', 'DASH'])
column_by_search = ["BTC", "ETH", "DASH"]
print(df)
for i,column in enumerate(column_by_search):
ema=[]
# over and over for each day that follows day 23 to get the full range of EMA
for j in range(0, len(column)-24):
# Add the closing prices for the first 22 days together and divide them by 22.
EMA_yesterday = column.iloc[1+j:22+j].mean()
k = float(2)/(22+1)
# getting the first EMA day by taking the following day’s (day 23) …Run Code Online (Sandbox Code Playgroud)