Skip to content

DOC: Update the pandas.Index.isna docstring #20123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Mar 12, 2018
36 changes: 33 additions & 3 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2022,18 +2022,48 @@ def hasnans(self):

def isna(self):
"""
Detect missing values
Detect missing values.

Return a boolean same-sized object indicating if the values are NA.
NA values, such as None or :attr:`numpy.NaN`, get mapped to True
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or pd.NaT

values.
Everything else get mapped to False values. Characters such as empty
strings `''` or :attr:`numpy.inf` are not considered NA values
(unless you set :attr:`pandas.options.mode.use_inf_as_na` `= True`).

.. versionadded:: 0.20.0

Returns
-------
a boolean array of whether my values are NA
numpy.ndarray
A boolean array of whether my values are NA

See also
--------
isnull : alias of isna
pandas.Index.isnull : alias of isna
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could say this is a synonym

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not my native language, I went with the language that was originally used. I can change it across all docs we have commited fi you'd like to, @jreback . Y/N?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh sorry, yes alias is fine.

pandas.Index.notna : boolean inverse of isna
pandas.Index.dropna : omit entries with missing values
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add Series.isna

pandas.isna : top-level isna

Examples
--------
Show which entries in a pandas.Index are NA. The result is an
array.

>>> idx = pd.Index([5.2, 6.0, np.NaN])
>>> idx
Float64Index([5.2, 6.0, nan], dtype='float64')
>>> idx.isna()
array([False, False, True])

Empty strings are not considered NA values. None is considered an NA
value.

>>> idx = pd.Index(['black', '', 'red', None])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you show a datetimeindex example (with has a NaT)

>>> idx
Index(['black', '', 'red', None], dtype='object')
>>> idx.isna()
array([False, False, False, True])
"""
return self._isnan
isnull = isna
Expand Down