1

I am trying to avoid using list of lists and appending during my loop, so I've figured I can create a large np.zeros array, then use np.split to split it in batches, and populate the batches. The code looks like this:

N = inputData.size - len(inputData.columns) * (days_decay + 1)
all_params = np.zeros([N, 1])
all_params = np.split(all_params, len(inputData.columns))
for i, fx in enumerate(inputData.columns):
    fx_spots = inputData[fx]
    [ewma_vola, rets, ewma_mean] = compute_ewma(fx_spots, 0.98, 124)
    param_ts = rets[(days_decay + 1):] / ewma_vola[:-1]
    param_ts = param_ts.reshape(param_ts.shape[0], 1)
    all_params[:][i] = param_ts

Note that at the end, for each iteration, all_params[:][i].shape == param_ts.shape. For some reason, the arrays within the array are all np.zeros after the loop instead of being populated. Any ideas what am I doing wrong?

Thanks!

PS I also do not know if this is going to be faster than list of lists and appending, but I wanted to experiment a little bit as well. It might not even be worth it at the end.

deblue
  • 277
  • 4
  • 18

0 Answers0