Skip to content

Commit 1e09c37

Browse files
wdyy20041223wdyy20041223
andauthored
DOC: Inline docstrings in pandas\core\generic.py file for methods: is… (#62891)
Co-authored-by: wdyy20041223 <2795352227@qq,com>
1 parent 7ebabd1 commit 1e09c37

File tree

2 files changed

+88
-17
lines changed

2 files changed

+88
-17
lines changed

pandas/core/generic.py

Lines changed: 86 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8156,7 +8156,6 @@ def asof(self, where, subset=None):
81568156
# ----------------------------------------------------------------------
81578157
# Action Methods
81588158

8159-
@doc(klass=_shared_doc_kwargs["klass"])
81608159
def isna(self) -> Self:
81618160
"""
81628161
Detect missing values.
@@ -8169,15 +8168,18 @@ def isna(self) -> Self:
81698168
81708169
Returns
81718170
-------
8172-
{klass}
8173-
Mask of bool values for each element in {klass} that
8174-
indicates whether an element is an NA value.
8171+
Series/DataFrame
8172+
Mask of bool values for each element in Series/DataFrame
8173+
that indicates whether an element is an NA value.
81758174
81768175
See Also
81778176
--------
8178-
{klass}.isnull : Alias of isna.
8179-
{klass}.notna : Boolean inverse of isna.
8180-
{klass}.dropna : Omit axes labels with missing values.
8177+
Series.isnull : Alias of isna.
8178+
DataFrame.isnull : Alias of isna.
8179+
Series.notna : Boolean inverse of isna.
8180+
DataFrame.notna : Boolean inverse of isna.
8181+
Series.dropna : Omit axes labels with missing values.
8182+
DataFrame.dropna : Omit axes labels with missing values.
81818183
isna : Top-level isna.
81828184
81838185
Examples
@@ -8225,11 +8227,77 @@ def isna(self) -> Self:
82258227
"""
82268228
return isna(self).__finalize__(self, method="isna")
82278229

8228-
@doc(isna, klass=_shared_doc_kwargs["klass"])
82298230
def isnull(self) -> Self:
8231+
"""
8232+
Detect missing values.
8233+
8234+
Return a boolean same-sized object indicating if the values are NA.
8235+
NA values, such as None or :attr:`numpy.NaN`, gets mapped to True
8236+
values.
8237+
Everything else gets mapped to False values. Characters such as empty
8238+
strings ``''`` or :attr:`numpy.inf` are not considered NA values.
8239+
8240+
Returns
8241+
-------
8242+
Series/DataFrame
8243+
Mask of bool values for each element in Series/DataFrame
8244+
that indicates whether an element is an NA value.
8245+
8246+
See Also
8247+
--------
8248+
Series.isna : Alias of isnull.
8249+
DataFrame.isna : Alias of isnull.
8250+
Series.notna : Boolean inverse of isnull.
8251+
DataFrame.notna : Boolean inverse of isnull.
8252+
Series.dropna : Omit axes labels with missing values.
8253+
DataFrame.dropna : Omit axes labels with missing values.
8254+
isna : Top-level isna.
8255+
8256+
Examples
8257+
--------
8258+
Show which entries in a DataFrame are NA.
8259+
8260+
>>> df = pd.DataFrame(
8261+
... dict(
8262+
... age=[5, 6, np.nan],
8263+
... born=[
8264+
... pd.NaT,
8265+
... pd.Timestamp("1939-05-27"),
8266+
... pd.Timestamp("1940-04-25"),
8267+
... ],
8268+
... name=["Alfred", "Batman", ""],
8269+
... toy=[None, "Batmobile", "Joker"],
8270+
... )
8271+
... )
8272+
>>> df
8273+
age born name toy
8274+
0 5.0 NaT Alfred NaN
8275+
1 6.0 1939-05-27 Batman Batmobile
8276+
2 NaN 1940-04-25 Joker
8277+
8278+
>>> df.isna()
8279+
age born name toy
8280+
0 False True False True
8281+
1 False False False False
8282+
2 True False False False
8283+
8284+
Show which entries in a Series are NA.
8285+
8286+
>>> ser = pd.Series([5, 6, np.nan])
8287+
>>> ser
8288+
0 5.0
8289+
1 6.0
8290+
2 NaN
8291+
dtype: float64
8292+
8293+
>>> ser.isna()
8294+
0 False
8295+
1 False
8296+
2 True
8297+
dtype: bool
8298+
"""
82308299
return isna(self).__finalize__(self, method="isnull")
82318300

8232-
@doc(klass=_shared_doc_kwargs["klass"])
82338301
def notna(self) -> Self:
82348302
"""
82358303
Detect existing (non-missing) values.
@@ -8242,15 +8310,18 @@ def notna(self) -> Self:
82428310
82438311
Returns
82448312
-------
8245-
{klass}
8246-
Mask of bool values for each element in {klass} that
8247-
indicates whether an element is not an NA value.
8313+
Series/DataFrame
8314+
Mask of bool values for each element in Series/DataFrame
8315+
that indicates whether an element is not an NA value.
82488316
82498317
See Also
82508318
--------
8251-
{klass}.notnull : Alias of notna.
8252-
{klass}.isna : Boolean inverse of notna.
8253-
{klass}.dropna : Omit axes labels with missing values.
8319+
Series.notnull : Alias of notna.
8320+
DataFrame.notnull : Alias of notna.
8321+
Series.isna : Boolean inverse of notna.
8322+
DataFrame.isna : Boolean inverse of notna.
8323+
Series.dropna : Omit axes labels with missing values.
8324+
DataFrame.dropna : Omit axes labels with missing values.
82548325
notna : Top-level notna.
82558326
82568327
Examples

pandas/core/series.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6183,7 +6183,7 @@ def isna(self) -> Series:
61836183
return NDFrame.isna(self)
61846184

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

62626262
# error: Cannot determine type of 'notna'
6263-
@doc(NDFrame.notna, klass=_shared_doc_kwargs["klass"]) # type: ignore[has-type]
6263+
@doc(NDFrame.notna, klass=_shared_doc_kwargs["klass"])
62646264
def notnull(self) -> Series:
62656265
"""
62666266
Series.notnull is an alias for Series.notna.

0 commit comments

Comments
 (0)