diff --git a/doc/source/whatsnew/v1.4.0.rst b/doc/source/whatsnew/v1.4.0.rst index ac638e6bd3c6e..64d8e36177051 100644 --- a/doc/source/whatsnew/v1.4.0.rst +++ b/doc/source/whatsnew/v1.4.0.rst @@ -614,7 +614,6 @@ Other Deprecations - Deprecated silent dropping of columns that raised a ``TypeError``, ``DataError``, and some cases of ``ValueError`` in :meth:`Series.aggregate`, :meth:`DataFrame.aggregate`, :meth:`Series.groupby.aggregate`, and :meth:`DataFrame.groupby.aggregate` when used with a list (:issue:`43740`) - Deprecated casting behavior when setting timezone-aware value(s) into a timezone-aware :class:`Series` or :class:`DataFrame` column when the timezones do not match. Previously this cast to object dtype. In a future version, the values being inserted will be converted to the series or column's existing timezone (:issue:`37605`) - Deprecated casting behavior when passing an item with mismatched-timezone to :meth:`DatetimeIndex.insert`, :meth:`DatetimeIndex.putmask`, :meth:`DatetimeIndex.where` :meth:`DatetimeIndex.fillna`, :meth:`Series.mask`, :meth:`Series.where`, :meth:`Series.fillna`, :meth:`Series.shift`, :meth:`Series.replace`, :meth:`Series.reindex` (and :class:`DataFrame` column analogues). In the past this has cast to object dtype. In a future version, these will cast the passed item to the index or series's timezone (:issue:`37605`,:issue:`44940`) -- Deprecated the 'errors' keyword argument in :meth:`Series.where`, :meth:`DataFrame.where`, :meth:`Series.mask`, and :meth:`DataFrame.mask`; in a future version the argument will be removed (:issue:`44294`) - Deprecated the ``prefix`` keyword argument in :func:`read_csv` and :func:`read_table`, in a future version the argument will be removed (:issue:`43396`) - Deprecated passing non boolean argument to sort in :func:`concat` (:issue:`41518`) - Deprecated passing arguments as positional for :func:`read_fwf` other than ``filepath_or_buffer`` (:issue:`41485`): diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 02676fb78e699..1f43f34d0e58a 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -10933,7 +10933,7 @@ def where( inplace=False, axis=None, level=None, - errors=lib.no_default, + errors="raise", try_cast=lib.no_default, ): return super().where(cond, other, inplace, axis, level, errors, try_cast) @@ -10948,7 +10948,7 @@ def mask( inplace=False, axis=None, level=None, - errors=lib.no_default, + errors="raise", try_cast=lib.no_default, ): return super().mask(cond, other, inplace, axis, level, errors, try_cast) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 7876765f578ea..609c431ba8580 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -9009,7 +9009,7 @@ def _where( inplace=False, axis=None, level=None, - errors=lib.no_default, + errors="raise", ): """ Equivalent to public method `where`, except that `other` is not @@ -9017,14 +9017,6 @@ def _where( """ inplace = validate_bool_kwarg(inplace, "inplace") - if errors is not lib.no_default: - warnings.warn( - f"The 'errors' keyword in {type(self).__name__}.where and mask is " - "deprecated and will be removed in a future version.", - FutureWarning, - stacklevel=find_stack_level(), - ) - if axis is not None: axis = self._get_axis_number(axis) @@ -9160,7 +9152,7 @@ def where( inplace=False, axis=None, level=None, - errors=lib.no_default, + errors="raise", try_cast=lib.no_default, ): """ @@ -9193,9 +9185,6 @@ def where( - 'raise' : allow exceptions to be raised. - 'ignore' : suppress exceptions. On error return original object. - .. deprecated:: 1.4.0 - Previously was silently ignored. - try_cast : bool, default None Try to cast the result back to the input type (if possible). @@ -9316,7 +9305,7 @@ def mask( inplace=False, axis=None, level=None, - errors=lib.no_default, + errors="raise", try_cast=lib.no_default, ): diff --git a/pandas/tests/series/methods/test_fillna.py b/pandas/tests/series/methods/test_fillna.py index 19f61a0a2d6fc..9617565cab0b4 100644 --- a/pandas/tests/series/methods/test_fillna.py +++ b/pandas/tests/series/methods/test_fillna.py @@ -151,18 +151,15 @@ def test_fillna_consistency(self): ) tm.assert_series_equal(result, expected) - msg = "The 'errors' keyword in " - with tm.assert_produces_warning(FutureWarning, match=msg): - # where (we ignore the errors=) - result = ser.where( - [True, False], Timestamp("20130101", tz="US/Eastern"), errors="ignore" - ) + # where (we ignore the errors=) + result = ser.where( + [True, False], Timestamp("20130101", tz="US/Eastern"), errors="ignore" + ) tm.assert_series_equal(result, expected) - with tm.assert_produces_warning(FutureWarning, match=msg): - result = ser.where( - [True, False], Timestamp("20130101", tz="US/Eastern"), errors="ignore" - ) + result = ser.where( + [True, False], Timestamp("20130101", tz="US/Eastern"), errors="ignore" + ) tm.assert_series_equal(result, expected) # with a non-datetime