You probably do not need to be making lists and appending them to make your array. You can likely just do it all at once, which is faster since you can use numpy to do your loops instead of doing them yourself in pure python.
To answer your question, as others have said, you cannot access a nested list with two indices like you did. You can if you convert mean_data
to an array before not after you try to slice it:
R = np.array(mean_data)[:,0]
instead of
R = np.array(mean_data[:,0])
But, assuming mean_data has a shape nx3
, instead of
R = np.array(mean_data)[:,0]
P = np.array(mean_data)[:,1]
Z = np.array(mean_data)[:,2]
You can simply do
A = np.array(mean_data).mean(axis=0)
which averages over the 0
th axis and returns a length-n
array
But to my original point, I will make up some data to try to illustrate how you can do this without building any lists one item at a time: