I am using a 2D list, and I'd like to calculate its mean value by row. The following is my code:
import numpy as np
mylist = np.zeros((2,120)) # This gives you a 2 by 120 2D list with 2 rows, and 120 columns
average_list = np.zeros(120)
for col in xrange(120):
average_list[col] = np.mean(mylist[:][col])
However, the above chunk generates this:
IndexError: index 2 is out of bounds for axis 0 with size 2
As I find during debugging, the problem happens at the col
in np.mean(mylist[:][col])
May I know what am I wrong about this?
Thanks.