[SciPy-user] mean of recarray

Gabriel J.L. Beckers beckers@orn.mpg...
Tue Mar 6 10:56:05 CST 2007

Is there an easy way to get the mean of a record array?

There is a mean() method, but it doesn't seem to work for me.

In [1]: import numpy

In [2]: desc = numpy.dtype({'names':['a','b'],'formats':['d','d']})

In [3]: ar = numpy.array([(1.,2.),(3.,4.)],dtype=desc)

In [4]: ar.mean()
exceptions.TypeError                                 Traceback (most
recent call last)

/home/user/<ipython console> 

TypeError: cannot perform reduce with flexible type

I would actually be able to get the mean along the second axis, like
ar.mean(1). Can this be done in a simple way?

Cheers, Gabriel

More information about the SciPy-user mailing list