Skip to content

DOC: update the isna, isnull, notna and notnull docstring #20459

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 6 commits into from
Mar 26, 2018

Conversation

Cheukting
Copy link
Contributor

@Cheukting Cheukting commented Mar 22, 2018

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

Please include the output of the validation script below between the "```" ticks:

The validation script did not work on this docstring

If the validation script still gives errors, but you think there is a good reason
to deviate in this case (and there are certainly such cases), please state this
explicitly.

The validation script did not work on this docstring

@@ -29,7 +29,12 @@


def isna(obj):
"""Detect missing values (NaN in numeric arrays, None/NaN in object arrays)
"""Detect missing values for an array
Copy link
Contributor

Choose a reason for hiding this comment

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

End with a .

@@ -46,6 +51,18 @@ def isna(obj):
--------
pandas.notna: boolean inverse of pandas.isna
pandas.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.

Add Series.isna, DataFrame.isna, and Index.isna.

@@ -215,6 +237,18 @@ def notna(obj):
--------
pandas.isna : boolean inverse of pandas.notna
pandas.notnull : alias of notna

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.notna, DataFrame.notna, and Index.notna

@@ -200,6 +217,11 @@ def notna(obj):
"""Replacement for numpy.isfinite / -numpy.isnan which is suitable for use
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 shorten this to a single line? Can be similar to you docstring for isna, just flipped.

@TomAugspurger
Copy link
Contributor

TomAugspurger commented Mar 22, 2018

In the Parameters section, can you change arr to obj to match the function signature?

@codecov
Copy link

codecov bot commented Mar 22, 2018

Codecov Report

Merging #20459 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #20459   +/-   ##
=======================================
  Coverage   91.85%   91.85%           
=======================================
  Files         152      152           
  Lines       49235    49235           
=======================================
  Hits        45224    45224           
  Misses       4011     4011
Flag Coverage Δ
#multiple 90.24% <ø> (ø) ⬆️
#single 41.88% <ø> (ø) ⬆️
Impacted Files Coverage Δ
pandas/core/dtypes/missing.py 91.07% <ø> (ø) ⬆️

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 402ad45...eb38aef. Read the comment docs.

@jreback jreback added Docs Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate labels Mar 26, 2018
"""Detect missing values for an array-like object.

This function takes an array-like object, for each element, if it is
a missing value (`NaN` in numeric arrays, `None`/`NaN` in object arrays)
Copy link
Contributor

Choose a reason for hiding this comment

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

NaT in datetimelike

pandas.isnull: alias of isna
>>> pd.isna('dog')
False
>>> pd.isna(np.nan)
Copy link
Contributor

Choose a reason for hiding this comment

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

an you add blank lines between cases

[ 4., 5., nan]])
>>> pd.isna(array)
array([[False, True, False],
[False, False, True]])
Copy link
Contributor

Choose a reason for hiding this comment

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

an you show a datetimelike example (DatetimeIndex is good)

"""Detect non-missing values for an array-like object.

This function takes an array-like object, for each element, if it is *not*
a missing.value (`NaN` in numeric arrays, `None`/`NaN` in object arrays)
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above

False
>>> array
array([[ 1., nan, 3.],
[ 4., 5., nan]])
Copy link
Contributor

Choose a reason for hiding this comment

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

same


Returns
-------
isna : array-like of bool or bool
array-like of bool or bool
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you rephrase as bool or array-like of bool, so that it goes small to big?


Returns
-------
isna : array-like of bool or bool
array-like of bool or bool
Array or bool indicating whether an object is null or if an array is
Copy link
Contributor

Choose a reason for hiding this comment

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

This wording tripped me up. Could try rephrasing it? Maybe something like, "Indicator for missing values. For a scalar, input, a scalar boolean is returned. For an array-like input, and array (of the same type?) of booleans indicating NA values element-wise is returned.

Ho and others added 2 commits March 26, 2018 14:46
Reword types.

Reformat for linter.

PEP8.

Move example order.
@TomAugspurger TomAugspurger merged commit c36e9f7 into pandas-dev:master Mar 26, 2018
@TomAugspurger
Copy link
Contributor

Thanks @Cheukting !

javadnoorb pushed a commit to javadnoorb/pandas that referenced this pull request Mar 29, 2018
dworvos pushed a commit to dworvos/pandas that referenced this pull request Apr 2, 2018
kornilova203 pushed a commit to kornilova203/pandas that referenced this pull request Apr 23, 2018
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.

3 participants