is there are way to write this more comfortable in python?
quote_e[i] = [i, (1 * o +
2 * p +
3 * q +
4 * r +
5 * s +
6 * t +
7 * u +
8 * v +
9 * w +
10 * x +
11 * y +
12 * z) / 78]
The variables are from a list that was created before.
o = ema_12[i - 12][1]
p = ema_12[i - 11][1]
q = ema_12[i - 10][1]
r = ema_12[i - 9][1]
s = ema_12[i - 8][1]
t = ema_12[i - 7][1]
u = ema_12[i - 6][1]
v = ema_12[i - 5][1]
w = ema_12[i - 4][1]
x = ema_12[i - 3][1]
y = ema_12[i - 2][1]
z = ema_12[i - 1][1]
Thanks in advance.
Daniel
1 Answer 1
var_list =[ ema_12[i-j][1] for j in range(12,0,-1) ]
quote_e[i]=[i,(np.arange(1,13)*var_list)/78]
This creates your list of variable o to z.Here muliplication will be element-wise
I hope this is what you required
Sign up to request clarification or add additional context in comments.
1 Comment
Dan Ru
Thank you very much. That was what I was looking for.
lang-py
letters (uprising) * numbers (uprising). I hope that describes it better.o = ema_12[i - 12][1] p = ema_12[i - 11][1] q = ema_12[i - 10][1] r = ema_12[i - 9][1] s = ema_12[i - 8][1] t = ema_12[i - 7][1] u = ema_12[i - 6][1] v = ema_12[i - 5][1] w = ema_12[i - 4][1] x = ema_12[i - 3][1] y = ema_12[i - 2][1] z = ema_12[i - 1][1]