Python question.
I have a list (A) of numpy object arrays (B). I’d like to get the mean of one of the object variables for all the objects in the B array. Right now, I’m just parsing through the B array, summing the variable and dividing it by the number of objects in B. Is there a better or more pythonic way to do this?
It would also be great, if I could get the mean of all objects in the A list (i.e. all objects)
If you have a numpy array, you can just call the
meanmethod:If you have a list of numpy arrays, getting the mean of each numpy is just:
Or, if you’re trying to get the mean of all the elements (over all elements of B in A), use the
summethod: