From 88196f206e175431439c2acb47625f896706fee7 Mon Sep 17 00:00:00 2001 From: donk23 Date: Sat, 10 Mar 2018 16:33:22 +0100 Subject: [PATCH 1/3] DOC: update pandas.Index.notna --- pandas/core/indexes/base.py | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 52283e4e223b4..c50fa216737a4 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -2040,18 +2040,47 @@ def isna(self): def notna(self): """ - Inverse of isna + Detect existing (non-missing) values. + + Return a boolean same-sized object indicating if the values are not NA. + Non-missing values get mapped to True. Characters such as empty + strings `''` or :attr:`numpy.inf` are not considered NA values + (unless you set :attr:`pandas.options.mode.use_inf_as_na` `= True`). + NA values, such as None or :attr:`numpy.NaN`, get mapped to False + values. .. versionadded:: 0.20.0 Returns ------- - a boolean array of whether my values are not NA + bool of type numpy.ndarray + Boolean array to indicate which entries are not NA. See also -------- notnull : alias of notna + isna: inverse of notna pandas.notna : top-level notna + + Examples + -------- + Show which entries in a pandas.Index are not NA. The result is an + array. + + >>> idx = pd.Index([5.2, 6.0, np.NaN]) + >>> idx + Float64Index([5.2, 6.0, nan], dtype='float64') + >>> idx.notna() + array([ True, True, False]) + + Empty strings are not considered NA values. None is considered a NA + value. + + >>> idx = pd.Index(['black', '', 'red', None]) + >>> idx + Index(['black', '', 'red', None], dtype='object') + >>> idx.notna() + array([ True, True, True, False]) """ return ~self.isna() notnull = notna From a8ce45e114cead3b3782082c577d9b813225f1e9 Mon Sep 17 00:00:00 2001 From: donK23 Date: Sat, 10 Mar 2018 16:56:58 +0100 Subject: [PATCH 2/3] added formatting quotes --- pandas/core/indexes/base.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index c50fa216737a4..5f8b16eb9fd8f 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -2043,10 +2043,10 @@ def notna(self): Detect existing (non-missing) values. Return a boolean same-sized object indicating if the values are not NA. - Non-missing values get mapped to True. Characters such as empty - strings `''` or :attr:`numpy.inf` are not considered NA values + Non-missing values get mapped to ``True``. Characters such as empty + strings ``''`` or :attr:`numpy.inf` are not considered NA values (unless you set :attr:`pandas.options.mode.use_inf_as_na` `= True`). - NA values, such as None or :attr:`numpy.NaN`, get mapped to False + NA values, such as None or :attr:`numpy.NaN`, get mapped to ``False`` values. .. versionadded:: 0.20.0 From e6aad429938b215396a1de8fe2c4b7a52ad32628 Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Mon, 12 Mar 2018 23:11:16 +0100 Subject: [PATCH 3/3] Update base.py --- pandas/core/indexes/base.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 5f8b16eb9fd8f..cbf0f7a70ff2f 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -2045,7 +2045,7 @@ def notna(self): Return a boolean same-sized object indicating if the values are not NA. Non-missing values get mapped to ``True``. Characters such as empty strings ``''`` or :attr:`numpy.inf` are not considered NA values - (unless you set :attr:`pandas.options.mode.use_inf_as_na` `= True`). + (unless you set ``pandas.options.mode.use_inf_as_na = True``). NA values, such as None or :attr:`numpy.NaN`, get mapped to ``False`` values. @@ -2053,18 +2053,18 @@ def notna(self): Returns ------- - bool of type numpy.ndarray + numpy.ndarray Boolean array to indicate which entries are not NA. See also -------- - notnull : alias of notna - isna: inverse of notna + Index.notnull : alias of notna + Index.isna: inverse of notna pandas.notna : top-level notna Examples -------- - Show which entries in a pandas.Index are not NA. The result is an + Show which entries in an Index are not NA. The result is an array. >>> idx = pd.Index([5.2, 6.0, np.NaN])