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
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion pandas/core/dtypes/missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 .


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)
the correisponding element of the output boolean array will be true,
otherwise false.

Parameters
----------
Expand All @@ -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.

Examples
--------
>>> df = pd.DataFrame([[1, pd.np.nan, 3], [4, 5, pd.np.nan]])
>>> df
0 1 2
0 1 NaN 3.0
1 4 5.0 NaN
>>> pd.isna(df)
0 1 2
0 False True False
1 False False True
"""
return _isna(obj)

Expand Down Expand Up @@ -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.

on object arrays.

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) the
correisponding element of the output boolean array will be true,
otherwise false.

Parameters
----------
arr : ndarray or object value
Expand All @@ -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

Examples
--------
>>> df = pd.DataFrame([[1, pd.np.nan, 3], [4, 5, pd.np.nan]])
>>> df
0 1 2
0 1 NaN 3.0
1 4 5.0 NaN
>>> pd.notna(df)
0 1 2
0 True False True
1 True True False
"""
res = isna(obj)
if is_scalar(res):
Expand Down