0

I have a really big matrix (3.600 x 30.000) which is a np array of np arrays, and I want to do the following process (this is not actual code!) to obtain the variance column-wise:

columnsArray = []
for column in matrix:
    newColumn = some_processing(column)
    columnsArray = np.append(columnsArray, newColumn)
variance = np.var(columnsArray)

I need it in order to calculate the variance of the processed values.

The problem is that the more columns I append, the slower the process becomes.

I also tried with np.column_stack, but it doesn't change much.

I'm sure there is a simpler way.

Alessandro
  • 103
  • 3
  • 11

0 Answers0