The numpy mean function works perfectly fine when the dimensions are the same.
a = np.array([[1, 2], [3, 4]])
a.mean(axis=1)
array([ 1.5, 3.5])
But if I do it with varrying row size it gives an error
a = np.array([[1, 2], [3, 4, 5]])
a.mean(axis=1)
IndexError: tuple index out of range
I cannot find anything on the documentation regarding this problem. I could calculate the mean myself but I would like to use the build in function for this, seeing that it should be possible.
See Question&Answers more detail:os