Quiero hacer calculos sobre tres columnas de un array values_array
.
def calculateAllEMA(self,values_array):
df = pd.DataFrame(values_array, columns=['BTC', 'ETH', 'DASH'])
for i,column in enumerate(df[column]):
ema=[]
for i in range(0, len(column)-24):
EMA_yesterday = column.iloc[1+i:22+i].mean()
k = float(2)/(22+1)
ema.append(column.iloc[23 + i]*k+EMA_yesterday*(1-k))
mean_exp[i] = ema[-1]
return mean_exp
Pero me dice :
for i,column in enumerate(df[column]):
UnboundLocalError: local variable 'column' referenced before assignment
Y no veo donde se referencia...
Aqui esta values_array
:
[(3554.05, 299.44, 198.51), (3554.05, 299.46, 198.51),
(3554.05, 299.55, 198.54), (3554.05, 299.55, 198.54),
(3554.05, 299.55, 198.54), (3554.05, 299.55, 198.51),
(3554.05, 299.44, 198.51), (3553.8, 299.64,198.49),
(3553.8, 299.65, 198.49), (3553.8, 299.65, 198.49),
(3553.8, 299.65, 198.49), (3553.8, 299.65, 198.49),
(3553.8, 299.64, 198.49), (3553.8, 299.65, 198.49),
(3553.8, 299.65, 198.49), (3553.8, 299.65, 198.49),
(3553.8, 299.65, 198.49), (3553.8, 299.64, 198.49),
(3553.91, 299.55, 198.54), (3553.8, 299.64, 198.49),
(3553.8, 299.65, 198.49), (3553.8, 299.69, 198.49),
(3553.8, 299.65, 198.49), (3553.8, 299.65, 198.49)]
KeyError: 0