Skip to content

Commit 31afaf8

Browse files
Donk23jorisvandenbossche
authored andcommitted
DOC: update the pandas.Index.notna docstring (#20180)
1 parent faba7ef commit 31afaf8

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

pandas/core/indexes/base.py

+32-3
Original file line numberDiff line numberDiff line change
@@ -2206,18 +2206,47 @@ def isna(self):
22062206

22072207
def notna(self):
22082208
"""
2209-
Inverse of isna
2209+
Detect existing (non-missing) values.
2210+
2211+
Return a boolean same-sized object indicating if the values are not NA.
2212+
Non-missing values get mapped to ``True``. Characters such as empty
2213+
strings ``''`` or :attr:`numpy.inf` are not considered NA values
2214+
(unless you set ``pandas.options.mode.use_inf_as_na = True``).
2215+
NA values, such as None or :attr:`numpy.NaN`, get mapped to ``False``
2216+
values.
22102217
22112218
.. versionadded:: 0.20.0
22122219
22132220
Returns
22142221
-------
2215-
a boolean array of whether my values are not NA
2222+
numpy.ndarray
2223+
Boolean array to indicate which entries are not NA.
22162224
22172225
See also
22182226
--------
2219-
notnull : alias of notna
2227+
Index.notnull : alias of notna
2228+
Index.isna: inverse of notna
22202229
pandas.notna : top-level notna
2230+
2231+
Examples
2232+
--------
2233+
Show which entries in an Index are not NA. The result is an
2234+
array.
2235+
2236+
>>> idx = pd.Index([5.2, 6.0, np.NaN])
2237+
>>> idx
2238+
Float64Index([5.2, 6.0, nan], dtype='float64')
2239+
>>> idx.notna()
2240+
array([ True, True, False])
2241+
2242+
Empty strings are not considered NA values. None is considered a NA
2243+
value.
2244+
2245+
>>> idx = pd.Index(['black', '', 'red', None])
2246+
>>> idx
2247+
Index(['black', '', 'red', None], dtype='object')
2248+
>>> idx.notna()
2249+
array([ True, True, True, False])
22212250
"""
22222251
return ~self.isna()
22232252
notnull = notna

0 commit comments

Comments
 (0)