-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
Conversation
pandas/core/dtypes/missing.py
Outdated
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
End with a .
pandas/core/dtypes/missing.py
Outdated
@@ -46,6 +51,18 @@ def isna(obj): | |||
-------- | |||
pandas.notna: boolean inverse of pandas.isna | |||
pandas.isnull: alias of isna | |||
|
There was a problem hiding this comment.
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.
pandas/core/dtypes/missing.py
Outdated
@@ -215,6 +237,18 @@ def notna(obj): | |||
-------- | |||
pandas.isna : boolean inverse of pandas.notna | |||
pandas.notnull : alias of notna | |||
|
There was a problem hiding this comment.
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
pandas/core/dtypes/missing.py
Outdated
@@ -200,6 +217,11 @@ def notna(obj): | |||
"""Replacement for numpy.isfinite / -numpy.isnan which is suitable for use |
There was a problem hiding this comment.
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.
In the Parameters section, can you change |
Codecov Report
@@ Coverage Diff @@
## master #20459 +/- ##
=======================================
Coverage 91.85% 91.85%
=======================================
Files 152 152
Lines 49235 49235
=======================================
Hits 45224 45224
Misses 4011 4011
Continue to review full report at Codecov.
|
pandas/core/dtypes/missing.py
Outdated
"""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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NaT in datetimelike
pandas/core/dtypes/missing.py
Outdated
pandas.isnull: alias of isna | ||
>>> pd.isna('dog') | ||
False | ||
>>> pd.isna(np.nan) |
There was a problem hiding this comment.
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]]) |
There was a problem hiding this comment.
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)
pandas/core/dtypes/missing.py
Outdated
"""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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
pandas/core/dtypes/missing.py
Outdated
False | ||
>>> array | ||
array([[ 1., nan, 3.], | ||
[ 4., 5., nan]]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
pandas/core/dtypes/missing.py
Outdated
|
||
Returns | ||
------- | ||
isna : array-like of bool or bool | ||
array-like of bool or bool |
There was a problem hiding this comment.
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?
pandas/core/dtypes/missing.py
Outdated
|
||
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 |
There was a problem hiding this comment.
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.
Thanks @Cheukting ! |
Checklist for the pandas documentation sprint (ignore this if you are doing
an unrelated PR):
scripts/validate_docstrings.py <your-function-or-method>
git diff upstream/master -u -- "*.py" | flake8 --diff
python doc/make.py --single <your-function-or-method>
Please include the output of the validation script below between the "```" ticks:
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