Skip to content

Commit b73d5f6

Browse files
jbrockmendelmeeseeksmachine
authored andcommitted
Backport PR pandas-dev#45334: DEPR: un-deprecate errors kwd reverts pandas-dev#44294
1 parent 92dc85a commit b73d5f6

File tree

4 files changed

+12
-27
lines changed

4 files changed

+12
-27
lines changed

doc/source/whatsnew/v1.4.0.rst

-1
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,6 @@ Other Deprecations
614614
- 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`)
615615
- 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`)
616616
- 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`)
617-
- 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`)
618617
- Deprecated the ``prefix`` keyword argument in :func:`read_csv` and :func:`read_table`, in a future version the argument will be removed (:issue:`43396`)
619618
- Deprecated passing non boolean argument to sort in :func:`concat` (:issue:`41518`)
620619
- Deprecated passing arguments as positional for :func:`read_fwf` other than ``filepath_or_buffer`` (:issue:`41485`):

pandas/core/frame.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -10931,7 +10931,7 @@ def where(
1093110931
inplace=False,
1093210932
axis=None,
1093310933
level=None,
10934-
errors=lib.no_default,
10934+
errors="raise",
1093510935
try_cast=lib.no_default,
1093610936
):
1093710937
return super().where(cond, other, inplace, axis, level, errors, try_cast)
@@ -10946,7 +10946,7 @@ def mask(
1094610946
inplace=False,
1094710947
axis=None,
1094810948
level=None,
10949-
errors=lib.no_default,
10949+
errors="raise",
1095010950
try_cast=lib.no_default,
1095110951
):
1095210952
return super().mask(cond, other, inplace, axis, level, errors, try_cast)

pandas/core/generic.py

+3-14
Original file line numberDiff line numberDiff line change
@@ -9002,22 +9002,14 @@ def _where(
90029002
inplace=False,
90039003
axis=None,
90049004
level=None,
9005-
errors=lib.no_default,
9005+
errors="raise",
90069006
):
90079007
"""
90089008
Equivalent to public method `where`, except that `other` is not
90099009
applied as a function even if callable. Used in __setitem__.
90109010
"""
90119011
inplace = validate_bool_kwarg(inplace, "inplace")
90129012

9013-
if errors is not lib.no_default:
9014-
warnings.warn(
9015-
f"The 'errors' keyword in {type(self).__name__}.where and mask is "
9016-
"deprecated and will be removed in a future version.",
9017-
FutureWarning,
9018-
stacklevel=find_stack_level(),
9019-
)
9020-
90219013
if axis is not None:
90229014
axis = self._get_axis_number(axis)
90239015

@@ -9153,7 +9145,7 @@ def where(
91539145
inplace=False,
91549146
axis=None,
91559147
level=None,
9156-
errors=lib.no_default,
9148+
errors="raise",
91579149
try_cast=lib.no_default,
91589150
):
91599151
"""
@@ -9186,9 +9178,6 @@ def where(
91869178
- 'raise' : allow exceptions to be raised.
91879179
- 'ignore' : suppress exceptions. On error return original object.
91889180
9189-
.. deprecated:: 1.4.0
9190-
Previously was silently ignored.
9191-
91929181
try_cast : bool, default None
91939182
Try to cast the result back to the input type (if possible).
91949183
@@ -9309,7 +9298,7 @@ def mask(
93099298
inplace=False,
93109299
axis=None,
93119300
level=None,
9312-
errors=lib.no_default,
9301+
errors="raise",
93139302
try_cast=lib.no_default,
93149303
):
93159304

pandas/tests/series/methods/test_fillna.py

+7-10
Original file line numberDiff line numberDiff line change
@@ -151,18 +151,15 @@ def test_fillna_consistency(self):
151151
)
152152
tm.assert_series_equal(result, expected)
153153

154-
msg = "The 'errors' keyword in "
155-
with tm.assert_produces_warning(FutureWarning, match=msg):
156-
# where (we ignore the errors=)
157-
result = ser.where(
158-
[True, False], Timestamp("20130101", tz="US/Eastern"), errors="ignore"
159-
)
154+
# where (we ignore the errors=)
155+
result = ser.where(
156+
[True, False], Timestamp("20130101", tz="US/Eastern"), errors="ignore"
157+
)
160158
tm.assert_series_equal(result, expected)
161159

162-
with tm.assert_produces_warning(FutureWarning, match=msg):
163-
result = ser.where(
164-
[True, False], Timestamp("20130101", tz="US/Eastern"), errors="ignore"
165-
)
160+
result = ser.where(
161+
[True, False], Timestamp("20130101", tz="US/Eastern"), errors="ignore"
162+
)
166163
tm.assert_series_equal(result, expected)
167164

168165
# with a non-datetime

0 commit comments

Comments
 (0)