Numpy: average over one dimension in “jagged” 3D array
问题 Suppose I have an N*M*X-dimensional array "data", where N and M are fixed, but X is variable for each entry data[n][m]. (Edit: To clarify, I just used np.array() on the 3D python list which I used for reading in the data, so the numpy array is of dimensions N*M and its entries are variable-length lists) I'd now like to compute the average over the X-dimension, so that I'm left with an N*M-dimensional array. Using np.average/mean with the axis-argument doesn't work, so the way I'm doing it