Skip to content

Commit b7b00c5

Browse files
Donk23jorisvandenbossche
authored andcommitted
DOC: update the pandas.DataFrame.notna and pandas.Series.notna docstring (#20160)
1 parent e7e0ea8 commit b7b00c5

File tree

1 file changed

+53
-4
lines changed

1 file changed

+53
-4
lines changed

pandas/core/generic.py

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5591,7 +5591,7 @@ def asof(self, where, subset=None):
55915591
NA values, such as None or :attr:`numpy.NaN`, gets mapped to True
55925592
values.
55935593
Everything else gets mapped to False values. Characters such as empty
5594-
strings `''` or :attr:`numpy.inf` are not considered NA values
5594+
strings ``''`` or :attr:`numpy.inf` are not considered NA values
55955595
(unless you set ``pandas.options.mode.use_inf_as_na = True``).
55965596
55975597
Returns
@@ -5653,14 +5653,63 @@ def isnull(self):
56535653
return isna(self).__finalize__(self)
56545654

56555655
_shared_docs['notna'] = """
5656-
Return a boolean same-sized object indicating if the values are
5657-
not NA.
5656+
Detect existing (non-missing) values.
5657+
5658+
Return a boolean same-sized object indicating if the values are not NA.
5659+
Non-missing values get mapped to True. Characters such as empty
5660+
strings ``''`` or :attr:`numpy.inf` are not considered NA values
5661+
(unless you set ``pandas.options.mode.use_inf_as_na = True``).
5662+
NA values, such as None or :attr:`numpy.NaN`, get mapped to False
5663+
values.
5664+
5665+
Returns
5666+
-------
5667+
%(klass)s
5668+
Mask of bool values for each element in %(klass)s that
5669+
indicates whether an element is not an NA value.
56585670
56595671
See Also
56605672
--------
5661-
%(klass)s.isna : boolean inverse of notna
56625673
%(klass)s.notnull : alias of notna
5674+
%(klass)s.isna : boolean inverse of notna
5675+
%(klass)s.dropna : omit axes labels with missing values
56635676
notna : top-level notna
5677+
5678+
Examples
5679+
--------
5680+
Show which entries in a DataFrame are not NA.
5681+
5682+
>>> df = pd.DataFrame({'age': [5, 6, np.NaN],
5683+
... 'born': [pd.NaT, pd.Timestamp('1939-05-27'),
5684+
... pd.Timestamp('1940-04-25')],
5685+
... 'name': ['Alfred', 'Batman', ''],
5686+
... 'toy': [None, 'Batmobile', 'Joker']})
5687+
>>> df
5688+
age born name toy
5689+
0 5.0 NaT Alfred None
5690+
1 6.0 1939-05-27 Batman Batmobile
5691+
2 NaN 1940-04-25 Joker
5692+
5693+
>>> df.notna()
5694+
age born name toy
5695+
0 True False True False
5696+
1 True True True True
5697+
2 False True True True
5698+
5699+
Show which entries in a Series are not NA.
5700+
5701+
>>> ser = pd.Series([5, 6, np.NaN])
5702+
>>> ser
5703+
0 5.0
5704+
1 6.0
5705+
2 NaN
5706+
dtype: float64
5707+
5708+
>>> ser.notna()
5709+
0 True
5710+
1 True
5711+
2 False
5712+
dtype: bool
56645713
"""
56655714

56665715
@Appender(_shared_docs['notna'] % _shared_doc_kwargs)

0 commit comments

Comments
 (0)