Hello Everyone this might be a stupid question however I am absolutely new to python programming and I can't figure out what I am doing wrong in this if loop:
price_a = train_predict
price_b = df_eval_1_long_III.reshape(-1,1)
price_c = df_eval_1_last_day.reshape(-1,1)
a = price_a > price_c
b = price_b > price_c
c = price_a < price_c
d = price_b < price_c
m = 0
n_m = 0
counter = 0
n_counter = 0
inactive_counter = 0
for len in (train_predict):
if ( a & b ).all():
counter += 1
m += (price_a - price_c)
elif (c & d).all():
n_counter += 1
n_m += (price_a - price_c) * (-1)
else:
inactive_counter += 1
print (m)
print (n_m)
print (counter)
print (n_counter)
print (inactive_counter)
The loop gives following output:
0
0
0
0
2400
Now this apparently at least cycles through the array. When I change the for statement to for i in len(train_predict): I get the error message that numpy is not callable
The first 5 array values of each price are below
train_predict[:5]
array([[1.28537 ],
[1.2874348],
[1.2903055],
[1.2867677],
[1.2895652]], dtype=float32)
df_eval_1_last_day.reshape(-1,1)[:5]
array([[1.28910828],
[1.28910828],
[1.29190624],
[1.28420818],
[1.29250741]])
df_eval_1_long_III.reshape(-1,1)[:5]
array([[1.28910828],
[1.29190624],
[1.28420818],
[1.29250741],
[1.29377818]])