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

Conversation

datadonK23
Copy link

Checklist for the pandas documentation sprint (ignore this if you are doing
an unrelated PR):

  • PR title is "DOC: update the docstring"
  • The validation script passes: scripts/validate_docstrings.py <your-function-or-method>
  • The PEP8 style check passes: git diff upstream/master -u -- "*.py" | flake8 --diff
  • The html version looks good: python doc/make.py --single <your-function-or-method>
  • It has been proofread on language by another sprint participant
################################################################################
######################## Docstring (pandas.Index.isna)  ########################
################################################################################

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
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
-------
numpy.ndarray
    A boolean array of whether my values are NA

See also
--------
pandas.Index.isnull : alias of isna
pandas.Index.notna : boolean inverse of isna
pandas.Index.dropna : omit entries with missing values
pandas.isna : top-level isna

Examples
--------
Show which entries in a pandas.Index are NA. The result is a
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 a NA
value.

>>> idx = pd.Index(['black', '', 'red', None])
>>> idx
Index(['black', '', 'red', None], dtype='object')
>>> idx.isna()
array([False, False, False,  True])

################################################################################
################################## Validation ##################################
################################################################################

Docstring for "pandas.Index.isna" correct. :)


Examples
--------
Show which entries in a pandas.Index are NA. The result is a
Copy link
Contributor

Choose a reason for hiding this comment

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

a -> an. array to numpy.ndarray.

Copy link
Author

@datadonK23 datadonK23 Mar 10, 2018

Choose a reason for hiding this comment

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

We left it as 'array', because you can see the data type in the returns section (recommended as more user friendly by @jorisvandenbossche )

>>> idx.isna()
array([False, False, True])

Empty strings are not considered NA values. None is considered a NA
Copy link
Contributor

Choose a reason for hiding this comment

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

a -> an.

@TomAugspurger
Copy link
Contributor

Just a couple minor grammar things, otherwise this LGTM.

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

isnull : alias of isna
pandas.Index.isnull : alias of isna
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


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.

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)

@jreback jreback added Docs Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate labels Mar 10, 2018
@codecov
Copy link

codecov bot commented Mar 10, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@fb556ed). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master   #20123   +/-   ##
=========================================
  Coverage          ?    91.7%           
=========================================
  Files             ?      150           
  Lines             ?    49152           
  Branches          ?        0           
=========================================
  Hits              ?    45074           
  Misses            ?     4078           
  Partials          ?        0
Flag Coverage Δ
#multiple 90.08% <ø> (?)
#single 41.84% <ø> (?)
Impacted Files Coverage Δ
pandas/core/indexes/base.py 96.66% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fb556ed...195421e. Read the comment docs.

@TomAugspurger TomAugspurger added this to the 0.23.0 milestone Mar 12, 2018
@TomAugspurger TomAugspurger merged commit faba7ef into pandas-dev:master Mar 12, 2018
@TomAugspurger
Copy link
Contributor

Thanks @Donk23!

@datadonK23 datadonK23 deleted the docstring_index_isna branch March 14, 2018 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants