I want to do calculations on three columns of an 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
But he tells me:
for i,column in enumerate(df[column]):
UnboundLocalError: local variable 'column' referenced before assignment
And I do not see where it is referenced ...
Here is 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)]