[SciPy-User] scipy.stats.nanmedian

Keith Goodman kwgoodman at gmail.com
Thu Jan 21 22:01:17 EST 2010


On Thu, Jan 21, 2010 at 6:41 PM, Pierre GM <pgmdevlist at gmail.com> wrote:
> On Jan 21, 2010, at 9:28 PM, Keith Goodman wrote:
>> That's the only was I was able to figure out how to pull 1.0 out of
>> np.array(1.0). Is there a better way?
>
>
> .item()

Thanks. item() looks better than tolist().

I simplified the function:

def nanmedian(x, axis=0):
    x, axis = _chk_asarray(x,axis)
    if x.ndim == 0:
        return float(x.item())
    x = x.copy()
    x = np.apply_along_axis(_nanmedian,axis,x)
    if x.ndim == 0:
        x = float(x.item())
    return x

and opened a ticket:

http://projects.scipy.org/scipy/ticket/1098



More information about the SciPy-User mailing list