diff --git a/pandas/core/categorical.py b/pandas/core/categorical.py index 79ab25266770a4..3ef720856f90c6 100644 --- a/pandas/core/categorical.py +++ b/pandas/core/categorical.py @@ -35,7 +35,7 @@ from pandas.core.missing import interpolate_2d from pandas.compat.numpy import function as nv from pandas.util._decorators import ( - Appender, cache_readonly, deprecate_kwarg, deprecate, Substitution) + Appender, cache_readonly, deprecate_kwarg, Substitution) from pandas.io.formats.terminal import get_terminal_size from pandas.util._validators import validate_bool_kwarg @@ -1179,7 +1179,7 @@ def isna(self): # we only have one NA in categories ret = np.logical_or(ret, self._codes == nan_pos) return ret - isnull = deprecate('isna', isna, klass=DeprecationWarning) + isnull = isna def notna(self): """ @@ -1199,7 +1199,7 @@ def notna(self): """ return ~self.isna() - notnull = deprecate('notna', notna, klass=DeprecationWarning) + notnull = notna def put(self, *args, **kwargs): """ diff --git a/pandas/core/dtypes/missing.py b/pandas/core/dtypes/missing.py index 2932218c5dd86b..7611c762540fba 100644 --- a/pandas/core/dtypes/missing.py +++ b/pandas/core/dtypes/missing.py @@ -1,7 +1,6 @@ """ missing types & inference """ -import warnings import numpy as np from pandas._libs import lib from pandas._libs.tslib import NaT, iNaT @@ -45,10 +44,7 @@ def isna(obj): return _isna(obj) -def isnull(obj): - warnings.warn("isnull is deprecated. Use isna instead", - DeprecationWarning, stacklevel=2) - return isna(obj) +isnull = isna def _isna_new(obj): @@ -217,10 +213,7 @@ def notna(obj): return ~res -def notnull(obj): - warnings.warn("notnull is deprecated. Use notna instead", - DeprecationWarning, stacklevel=2) - return notna(obj) +notnull = notna def is_null_datelike_scalar(other): diff --git a/pandas/core/generic.py b/pandas/core/generic.py index afdc7a3a7dcfb4..e1a8c54a1d4f53 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -54,7 +54,7 @@ from pandas.core.ops import _align_method_FRAME import pandas.core.nanops as nanops from pandas.util._decorators import (Appender, Substitution, - deprecate, deprecate_kwarg) + deprecate_kwarg) from pandas.util._validators import validate_bool_kwarg from pandas.core import config @@ -4462,7 +4462,7 @@ def asof(self, where, subset=None): @Appender(_shared_docs['isna']) def isna(self): return isna(self).__finalize__(self) - isnull = deprecate('isna', isna, klass=DeprecationWarning) + isnull = isna _shared_docs['notna'] = """ Return a boolean same-sized object indicating if the values are @@ -4476,7 +4476,7 @@ def isna(self): @Appender(_shared_docs['notna']) def notna(self): return notna(self).__finalize__(self) - notnull = deprecate('notna', notna, klass=DeprecationWarning) + notnull = notna def _clip_with_scalar(self, lower, upper, inplace=False): if ((lower is not None and np.any(isna(lower))) or diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index bbec36f4eaa92f..931e6df78ebee2 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -43,7 +43,7 @@ from pandas.core.base import PandasObject, IndexOpsMixin import pandas.core.base as base from pandas.util._decorators import ( - Appender, Substitution, cache_readonly, deprecate, deprecate_kwarg) + Appender, Substitution, cache_readonly, deprecate_kwarg) from pandas.core.indexes.frozen import FrozenList import pandas.core.common as com import pandas.core.dtypes.concat as _concat @@ -1859,7 +1859,7 @@ def isna(self): pandas.isna : pandas version """ return self._isnan - isnull = deprecate('isna', isna, klass=DeprecationWarning) + isnull = isna def notna(self): """ @@ -1876,7 +1876,7 @@ def notna(self): pandas.notna : pandas version """ return ~self.isna() - notnull = deprecate('notna', notna, klass=DeprecationWarning) + notnull = notna def putmask(self, mask, value): """ diff --git a/pandas/core/sparse/frame.py b/pandas/core/sparse/frame.py index ea040dec18f62d..d8c0aa41edac1f 100644 --- a/pandas/core/sparse/frame.py +++ b/pandas/core/sparse/frame.py @@ -26,7 +26,7 @@ import pandas.core.generic as generic from pandas.core.sparse.series import SparseSeries, SparseArray from pandas._libs.sparse import BlockIndex, get_blocks -from pandas.util._decorators import Appender, deprecate +from pandas.util._decorators import Appender import pandas.core.ops as ops @@ -788,12 +788,12 @@ def cumsum(self, axis=0, *args, **kwargs): @Appender(generic._shared_docs['isna']) def isna(self): return self._apply_columns(lambda x: x.isna()) - isnull = deprecate('isna', isna, klass=DeprecationWarning) + isnull = isna @Appender(generic._shared_docs['notna']) def notna(self): return self._apply_columns(lambda x: x.notna()) - notnull = deprecate('notna', notna, klass=DeprecationWarning) + notnull = notna def apply(self, func, axis=0, broadcast=False, reduce=False): """ diff --git a/pandas/core/sparse/series.py b/pandas/core/sparse/series.py index 6ab6ce3b0c034d..62d20e73dbfcbd 100644 --- a/pandas/core/sparse/series.py +++ b/pandas/core/sparse/series.py @@ -28,7 +28,6 @@ _make_index) from pandas._libs.sparse import BlockIndex, IntIndex import pandas._libs.sparse as splib -from pandas.util._decorators import deprecate from pandas.core.sparse.scipy_sparse import ( _sparse_series_to_coo, @@ -648,7 +647,7 @@ def isna(self): sparse_index=self.values.sp_index, fill_value=isna(self.fill_value)) return self._constructor(arr, index=self.index).__finalize__(self) - isnull = deprecate('isna', isna, klass=DeprecationWarning) + isnull = isna @Appender(generic._shared_docs['notna']) def notna(self): @@ -656,7 +655,7 @@ def notna(self): sparse_index=self.values.sp_index, fill_value=notna(self.fill_value)) return self._constructor(arr, index=self.index).__finalize__(self) - notnull = deprecate('notna', notna, klass=DeprecationWarning) + notnull = notna def dropna(self, axis=0, inplace=False, **kwargs): """ diff --git a/pandas/tests/api/test_api.py b/pandas/tests/api/test_api.py index 29ff9c3a779712..433ed7e517b1cc 100644 --- a/pandas/tests/api/test_api.py +++ b/pandas/tests/api/test_api.py @@ -64,8 +64,8 @@ class TestPDApi(Base): funcs = ['bdate_range', 'concat', 'crosstab', 'cut', 'date_range', 'interval_range', 'eval', 'factorize', 'get_dummies', - 'infer_freq', 'isna', 'lreshape', - 'melt', 'notna', 'offsets', + 'infer_freq', 'isna', 'isnull', 'lreshape', + 'melt', 'notna', 'notnull', 'offsets', 'merge', 'merge_ordered', 'merge_asof', 'period_range', 'pivot', 'pivot_table', 'qcut', @@ -89,7 +89,7 @@ class TestPDApi(Base): 'to_numeric', 'to_pickle', 'to_timedelta'] # top-level to deprecate in the future - deprecated_funcs_in_future = ['isnull', 'notnull'] + deprecated_funcs_in_future = [] # these are already deprecated; awaiting removal deprecated_funcs = ['ewma', 'ewmcorr', 'ewmcov', 'ewmstd', 'ewmvar', diff --git a/pandas/tests/dtypes/test_missing.py b/pandas/tests/dtypes/test_missing.py index 9dfdaccc40eb6f..d3c9ca51af18fc 100644 --- a/pandas/tests/dtypes/test_missing.py +++ b/pandas/tests/dtypes/test_missing.py @@ -15,36 +15,37 @@ from pandas.core.dtypes.common import is_scalar from pandas.core.dtypes.dtypes import DatetimeTZDtype from pandas.core.dtypes.missing import ( - array_equivalent, isna, notna, + array_equivalent, isna, notna, isnull, notnull, na_value_for_dtype) -def test_notna(): - assert notna(1.) - assert not notna(None) - assert not notna(np.NaN) +@pytest.mark.parametrize('notna_f', [notna, notnull]) +def test_notna_notnull(notna_f): + assert notna_f(1.) + assert not notna_f(None) + assert not notna_f(np.NaN) with cf.option_context("mode.use_inf_as_na", False): - assert notna(np.inf) - assert notna(-np.inf) + assert notna_f(np.inf) + assert notna_f(-np.inf) arr = np.array([1.5, np.inf, 3.5, -np.inf]) - result = notna(arr) + result = notna_f(arr) assert result.all() with cf.option_context("mode.use_inf_as_na", True): - assert not notna(np.inf) - assert not notna(-np.inf) + assert not notna_f(np.inf) + assert not notna_f(-np.inf) arr = np.array([1.5, np.inf, 3.5, -np.inf]) - result = notna(arr) + result = notna_f(arr) assert result.sum() == 2 with cf.option_context("mode.use_inf_as_na", False): for s in [tm.makeFloatSeries(), tm.makeStringSeries(), tm.makeObjectSeries(), tm.makeTimeSeries(), tm.makePeriodSeries()]: - assert (isinstance(isna(s), Series)) + assert (isinstance(notna_f(s), Series)) class TestIsNA(object): @@ -66,40 +67,41 @@ def test_empty_object(self): expected = np.ones(shape=shape, dtype=bool) tm.assert_numpy_array_equal(result, expected) - def test_isna(self): - assert not isna(1.) - assert isna(None) - assert isna(np.NaN) + @pytest.mark.parametrize('isna_f', [isna, isnull]) + def test_isna_isnull(self, isna_f): + assert not isna_f(1.) + assert isna_f(None) + assert isna_f(np.NaN) assert float('nan') - assert not isna(np.inf) - assert not isna(-np.inf) + assert not isna_f(np.inf) + assert not isna_f(-np.inf) # series for s in [tm.makeFloatSeries(), tm.makeStringSeries(), tm.makeObjectSeries(), tm.makeTimeSeries(), tm.makePeriodSeries()]: - assert isinstance(isna(s), Series) + assert isinstance(isna_f(s), Series) # frame for df in [tm.makeTimeDataFrame(), tm.makePeriodFrame(), tm.makeMixedDataFrame()]: - result = isna(df) - expected = df.apply(isna) + result = isna_f(df) + expected = df.apply(isna_f) tm.assert_frame_equal(result, expected) # panel with catch_warnings(record=True): for p in [tm.makePanel(), tm.makePeriodPanel(), tm.add_nans(tm.makePanel())]: - result = isna(p) - expected = p.apply(isna) + result = isna_f(p) + expected = p.apply(isna_f) tm.assert_panel_equal(result, expected) # panel 4d with catch_warnings(record=True): for p in [tm.makePanel4D(), tm.add_nans_panel4d(tm.makePanel4D())]: - result = isna(p) - expected = p.apply(isna) + result = isna_f(p) + expected = p.apply(isna_f) tm.assert_panel4d_equal(result, expected) def test_isna_lists(self): @@ -331,13 +333,3 @@ def test_na_value_for_dtype(): for dtype in ['O']: assert np.isnan(na_value_for_dtype(np.dtype(dtype))) - - -@pytest.mark.parametrize("func", [pd.notnull, pd.isnull]) -def test_deprecation_deprecations(func): - - # top level deprecations - # 15001 - with tm.assert_produces_warning(DeprecationWarning, - check_stacklevel=False): - func('foo')