Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
101 changes: 86 additions & 15 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -8156,7 +8156,6 @@ def asof(self, where, subset=None):
# ----------------------------------------------------------------------
# Action Methods

@doc(klass=_shared_doc_kwargs["klass"])
def isna(self) -> Self:
"""
Detect missing values.
Expand All @@ -8169,15 +8168,18 @@ def isna(self) -> Self:

Returns
-------
{klass}
Mask of bool values for each element in {klass} that
indicates whether an element is an NA value.
Series/DataFrame
Mask of bool values for each element in Series/DataFrame
that indicates whether an element is an NA value.

See Also
--------
{klass}.isnull : Alias of isna.
{klass}.notna : Boolean inverse of isna.
{klass}.dropna : Omit axes labels with missing values.
Series.isnull : Alias of isna.
DataFrame.isnull : Alias of isna.
Series.notna : Boolean inverse of isna.
DataFrame.notna : Boolean inverse of isna.
Series.dropna : Omit axes labels with missing values.
DataFrame.dropna : Omit axes labels with missing values.
isna : Top-level isna.

Examples
Expand Down Expand Up @@ -8225,11 +8227,77 @@ def isna(self) -> Self:
"""
return isna(self).__finalize__(self, method="isna")

@doc(isna, klass=_shared_doc_kwargs["klass"])
def isnull(self) -> Self:
"""
Detect missing values.

Return a boolean same-sized object indicating if the values are NA.
NA values, such as None or :attr:`numpy.NaN`, gets mapped to True
values.
Everything else gets mapped to False values. Characters such as empty
strings ``''`` or :attr:`numpy.inf` are not considered NA values.

Returns
-------
Series/DataFrame
Mask of bool values for each element in Series/DataFrame
that indicates whether an element is an NA value.

See Also
--------
Series.isna : Alias of isnull.
DataFrame.isna : Alias of isnull.
Series.notna : Boolean inverse of isnull.
DataFrame.notna : Boolean inverse of isnull.
Series.dropna : Omit axes labels with missing values.
DataFrame.dropna : Omit axes labels with missing values.
isna : Top-level isna.

Examples
--------
Show which entries in a DataFrame are NA.

>>> df = pd.DataFrame(
... dict(
... age=[5, 6, np.nan],
... born=[
... pd.NaT,
... pd.Timestamp("1939-05-27"),
... pd.Timestamp("1940-04-25"),
... ],
... name=["Alfred", "Batman", ""],
... toy=[None, "Batmobile", "Joker"],
... )
... )
>>> df
age born name toy
0 5.0 NaT Alfred NaN
1 6.0 1939-05-27 Batman Batmobile
2 NaN 1940-04-25 Joker

>>> df.isna()
age born name toy
0 False True False True
1 False False False False
2 True False False False

Show which entries in a Series are NA.

>>> ser = pd.Series([5, 6, np.nan])
>>> ser
0 5.0
1 6.0
2 NaN
dtype: float64

>>> ser.isna()
0 False
1 False
2 True
dtype: bool
"""
return isna(self).__finalize__(self, method="isnull")

@doc(klass=_shared_doc_kwargs["klass"])
def notna(self) -> Self:
"""
Detect existing (non-missing) values.
Expand All @@ -8242,15 +8310,18 @@ def notna(self) -> Self:

Returns
-------
{klass}
Mask of bool values for each element in {klass} that
indicates whether an element is not an NA value.
Series/DataFrame
Mask of bool values for each element in Series/DataFrame
that indicates whether an element is not an NA value.

See Also
--------
{klass}.notnull : Alias of notna.
{klass}.isna : Boolean inverse of notna.
{klass}.dropna : Omit axes labels with missing values.
Series.notnull : Alias of notna.
DataFrame.notnull : Alias of notna.
Series.isna : Boolean inverse of notna.
DataFrame.isna : Boolean inverse of notna.
Series.dropna : Omit axes labels with missing values.
DataFrame.dropna : Omit axes labels with missing values.
notna : Top-level notna.

Examples
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -6183,7 +6183,7 @@ def isna(self) -> Series:
return NDFrame.isna(self)

# error: Cannot determine type of 'isna'
@doc(NDFrame.isna, klass=_shared_doc_kwargs["klass"]) # type: ignore[has-type]
@doc(NDFrame.isna, klass=_shared_doc_kwargs["klass"])
def isnull(self) -> Series:
"""
Series.isnull is an alias for Series.isna.
Expand Down Expand Up @@ -6260,7 +6260,7 @@ def notna(self) -> Series:
return super().notna()

# error: Cannot determine type of 'notna'
@doc(NDFrame.notna, klass=_shared_doc_kwargs["klass"]) # type: ignore[has-type]
@doc(NDFrame.notna, klass=_shared_doc_kwargs["klass"])
def notnull(self) -> Series:
"""
Series.notnull is an alias for Series.notna.
Expand Down
Loading