diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index d9f545969d9f7..662bf04595026 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -2559,7 +2559,7 @@ def notna(self) -> npt.NDArray[np.bool_]: notnull = notna - def fillna(self, value=None, downcast=lib.no_default): + def fillna(self, value=None): """ Fill NA/NaN values with the specified value. @@ -2568,12 +2568,6 @@ def fillna(self, value=None, downcast=lib.no_default): value : scalar Scalar value to use to fill holes (e.g. 0). This value cannot be a list-likes. - downcast : dict, default is None - A dict of item->dtype of what to downcast if possible, - or the string 'infer' which will try to downcast to an appropriate - equal type (e.g. float64 to int64 if possible). - - .. deprecated:: 2.1.0 Returns ------- @@ -2592,28 +2586,13 @@ def fillna(self, value=None, downcast=lib.no_default): """ if not is_scalar(value): raise TypeError(f"'value' must be a scalar, passed: {type(value).__name__}") - if downcast is not lib.no_default: - warnings.warn( - f"The 'downcast' keyword in {type(self).__name__}.fillna is " - "deprecated and will be removed in a future version. " - "It was previously silently ignored.", - FutureWarning, - stacklevel=find_stack_level(), - ) - else: - downcast = None if self.hasnans: result = self.putmask(self._isnan, value) - if downcast is None: - # no need to care metadata other than name - # because it can't have freq if it has NaTs - # _with_infer needed for test_fillna_categorical - return Index._with_infer(result, name=self.name) - raise NotImplementedError( - f"{type(self).__name__}.fillna does not support 'downcast' " - "argument values other than 'None'." - ) + # no need to care metadata other than name + # because it can't have freq if it has NaTs + # _with_infer needed for test_fillna_categorical + return Index._with_infer(result, name=self.name) return self._view() def dropna(self, how: AnyAll = "any") -> Self: diff --git a/pandas/tests/indexes/test_old_base.py b/pandas/tests/indexes/test_old_base.py index cc496dbee86d3..fa1b9f250f35f 100644 --- a/pandas/tests/indexes/test_old_base.py +++ b/pandas/tests/indexes/test_old_base.py @@ -597,13 +597,6 @@ def test_fillna(self, index): idx = type(index)(values) - msg = "does not support 'downcast'" - msg2 = r"The 'downcast' keyword in .*Index\.fillna is deprecated" - with tm.assert_produces_warning(FutureWarning, match=msg2): - with pytest.raises(NotImplementedError, match=msg): - # For now at least, we only raise if there are NAs present - idx.fillna(idx[0], downcast="infer") - expected = np.array([False] * len(idx), dtype=bool) expected[1] = True tm.assert_numpy_array_equal(idx._isnan, expected)