0

I have been searching the web for NaN in Python Numpy arrays and found some things I cannot reproduce. I am using the Anaconda distribution with numpy.version.version == 1.10.4

from numpy import NA as NA

only gets me a "cannot import NA". This NA module is mentioned in another stackoverflow thread

This same link also mentions maskna and skipna as NumPy parameters.

Alternatively, most array constructors (as of 1.7) have the parameter maskna, which you can set to True

This claim is also supported by the documentation from scypy.org

But again when I try this I only ever get an error:

a = np.arange(6, maskna=True)

gives me an encouraging "TypeError: 'maskna' is an invalid keyword argument for this function"

What is going on? Am I hunting a discontinued feature? Is this replaced by nansum(), nanmean() etc. But the documentation is 1.10.1 that's not far of 1.10.4.

How can I get this to work?

Community
  • 1
  • 1
cowiie
  • 1
  • 1
  • I think they meant ``numpy.ma`` instead of ``numpy.NA`` but I'm not sure. Use ``np.isfinite(array)`` to get all finite values or ``~np.isfinite(array)`` to get all infinite and ``NaN`` values as boolean masks. – MSeifert Mar 09 '16 at 01:43
  • you can also use `mask = np.isnan(array)` or `mask = ~np.isnan(array)` to get nan or not-nan values, then `my_finite_array = array[mask]` – 22degrees Mar 09 '16 at 02:02
  • The last comment of the accepted answer: ` The np.NA stuff apparently did not actually make it into 1.7. – Reid Jul 5 '13 at 20:48` – hpaulj Mar 09 '16 at 02:17
  • @hpaulj I see. But why is it in the 1.10 documentation I linked? np.ma with mask certainly works. For many things even nansum(), nanmean() a.s.o work fine. I am just curious as to why i cannot find the documented np.NA. – cowiie Mar 09 '16 at 02:43
  • That link you found is the first, and only reference I have seen to `np.NA`. It sounds like a feature that someone proposed, even developed, but which was ultimately rejected. There is a `ma`, masked array, subclass. But this `NA` apparently was something more fundamental. – hpaulj Mar 09 '16 at 02:58
  • 2
    What you found in the docs is a NEP - a proposal. Just that, nothing more. – hpaulj Mar 09 '16 at 03:04

0 Answers0