From 9f7b1c359d84bf5cc926f5c88655f967a95643cd Mon Sep 17 00:00:00 2001 From: richard Date: Sat, 23 Mar 2024 18:35:03 -0400 Subject: [PATCH] CLN: Enforce deprecations for EA.fillna --- doc/source/whatsnew/v3.0.0.rst | 2 +- pandas/core/arrays/_mixins.py | 32 ++----- pandas/core/arrays/arrow/array.py | 12 +-- pandas/core/arrays/base.py | 72 ++------------- pandas/core/arrays/interval.py | 24 +---- pandas/core/arrays/masked.py | 27 ++---- pandas/core/arrays/period.py | 13 --- pandas/core/arrays/sparse/array.py | 52 ++--------- pandas/core/generic.py | 2 - pandas/core/internals/blocks.py | 6 +- .../tests/arrays/categorical/test_missing.py | 28 ------ pandas/tests/extension/conftest.py | 2 +- pandas/tests/extension/decimal/array.py | 13 +-- .../tests/extension/decimal/test_decimal.py | 92 ------------------- pandas/tests/extension/test_arrow.py | 4 - pandas/tests/extension/test_string.py | 4 - 16 files changed, 38 insertions(+), 347 deletions(-) diff --git a/doc/source/whatsnew/v3.0.0.rst b/doc/source/whatsnew/v3.0.0.rst index f225d384888e3..76cb3cb1f2e81 100644 --- a/doc/source/whatsnew/v3.0.0.rst +++ b/doc/source/whatsnew/v3.0.0.rst @@ -34,7 +34,6 @@ Other enhancements - Allow dictionaries to be passed to :meth:`pandas.Series.str.replace` via ``pat`` parameter (:issue:`51748`) - Support passing a :class:`Series` input to :func:`json_normalize` that retains the :class:`Series` :class:`Index` (:issue:`51452`) - Users can globally disable any ``PerformanceWarning`` by setting the option ``mode.performance_warnings`` to ``False`` (:issue:`56920`) -- .. --------------------------------------------------------------------------- .. _whatsnew_300.notable_bug_fixes: @@ -258,6 +257,7 @@ Removal of prior version deprecations/changes - Unrecognized timezones when parsing strings to datetimes now raises a ``ValueError`` (:issue:`51477`) - Removed the :class:`Grouper` attributes ``ax``, ``groups``, ``indexer``, and ``obj`` (:issue:`51206`, :issue:`51182`) - Removed deprecated keyword ``verbose`` on :func:`read_csv` and :func:`read_table` (:issue:`56556`) +- Removed the ``method`` keyword in ``ExtensionArray.fillna``, implement ``ExtensionArray._pad_or_backfill`` instead (:issue:`53621`) - Removed the attribute ``dtypes`` from :class:`.DataFrameGroupBy` (:issue:`51997`) .. --------------------------------------------------------------------------- diff --git a/pandas/core/arrays/_mixins.py b/pandas/core/arrays/_mixins.py index c1d0ade572e8a..7f4e6f6666382 100644 --- a/pandas/core/arrays/_mixins.py +++ b/pandas/core/arrays/_mixins.py @@ -33,7 +33,6 @@ from pandas.util._decorators import doc from pandas.util._validators import ( validate_bool_kwarg, - validate_fillna_kwargs, validate_insert_loc, ) @@ -336,13 +335,7 @@ def _pad_or_backfill( return new_values @doc(ExtensionArray.fillna) - def fillna( - self, value=None, method=None, limit: int | None = None, copy: bool = True - ) -> Self: - value, method = validate_fillna_kwargs( - value, method, validate_scalar_dict_value=False - ) - + def fillna(self, value=None, limit: int | None = None, copy: bool = True) -> Self: mask = self.isna() # error: Argument 2 to "check_value_size" has incompatible type # "ExtensionArray"; expected "ndarray" @@ -353,25 +346,12 @@ def fillna( ) if mask.any(): - if method is not None: - # (for now) when self.ndim == 2, we assume axis=0 - func = missing.get_fill_func(method, ndim=self.ndim) - npvalues = self._ndarray.T - if copy: - npvalues = npvalues.copy() - func(npvalues, limit=limit, mask=mask.T) - npvalues = npvalues.T - - # TODO: NumpyExtensionArray didn't used to copy, need tests - # for this - new_values = self._from_backing_data(npvalues) + # fill with value + if copy: + new_values = self.copy() else: - # fill with value - if copy: - new_values = self.copy() - else: - new_values = self[:] - new_values[mask] = value + new_values = self[:] + new_values[mask] = value else: # We validate the fill_value even if there is nothing to fill if value is not None: diff --git a/pandas/core/arrays/arrow/array.py b/pandas/core/arrays/arrow/array.py index aaf43662ebde2..84b62563605ac 100644 --- a/pandas/core/arrays/arrow/array.py +++ b/pandas/core/arrays/arrow/array.py @@ -29,7 +29,6 @@ pa_version_under13p0, ) from pandas.util._decorators import doc -from pandas.util._validators import validate_fillna_kwargs from pandas.core.dtypes.cast import ( can_hold_element, @@ -1068,6 +1067,7 @@ def _pad_or_backfill( # a kernel for duration types. pass + # TODO: Why do we no longer need the above cases? # TODO(3.0): after EA.fillna 'method' deprecation is enforced, we can remove # this method entirely. return super()._pad_or_backfill( @@ -1078,21 +1078,15 @@ def _pad_or_backfill( def fillna( self, value: object | ArrayLike | None = None, - method: FillnaOptions | None = None, limit: int | None = None, copy: bool = True, ) -> Self: - value, method = validate_fillna_kwargs(value, method) - if not self._hasna: # TODO(CoW): Not necessary anymore when CoW is the default return self.copy() if limit is not None: - return super().fillna(value=value, method=method, limit=limit, copy=copy) - - if method is not None: - return super().fillna(method=method, limit=limit, copy=copy) + return super().fillna(value=value, limit=limit, copy=copy) if isinstance(value, (np.ndarray, ExtensionArray)): # Similar to check_value_size, but we do not mask here since we may @@ -1118,7 +1112,7 @@ def fillna( # a kernel for duration types. pass - return super().fillna(value=value, method=method, limit=limit, copy=copy) + return super().fillna(value=value, limit=limit, copy=copy) def isin(self, values: ArrayLike) -> npt.NDArray[np.bool_]: # short-circuit to return all False array. diff --git a/pandas/core/arrays/base.py b/pandas/core/arrays/base.py index 86831f072bb8f..76615704f2e33 100644 --- a/pandas/core/arrays/base.py +++ b/pandas/core/arrays/base.py @@ -38,7 +38,6 @@ from pandas.util._exceptions import find_stack_level from pandas.util._validators import ( validate_bool_kwarg, - validate_fillna_kwargs, validate_insert_loc, ) @@ -1007,31 +1006,6 @@ def _pad_or_backfill( [, 2, 2, 3, , ] Length: 6, dtype: Int64 """ - - # If a 3rd-party EA has implemented this functionality in fillna, - # we warn that they need to implement _pad_or_backfill instead. - if ( - type(self).fillna is not ExtensionArray.fillna - and type(self)._pad_or_backfill is ExtensionArray._pad_or_backfill - ): - # Check for _pad_or_backfill here allows us to call - # super()._pad_or_backfill without getting this warning - warnings.warn( - "ExtensionArray.fillna 'method' keyword is deprecated. " - "In a future version. arr._pad_or_backfill will be called " - "instead. 3rd-party ExtensionArray authors need to implement " - "_pad_or_backfill.", - DeprecationWarning, - stacklevel=find_stack_level(), - ) - if limit_area is not None: - raise NotImplementedError( - f"{type(self).__name__} does not implement limit_area " - "(added in pandas 2.2). 3rd-party ExtnsionArray authors " - "need to add this argument to _pad_or_backfill." - ) - return self.fillna(method=method, limit=limit) - mask = self.isna() if mask.any(): @@ -1057,8 +1031,7 @@ def _pad_or_backfill( def fillna( self, - value: object | ArrayLike | None = None, - method: FillnaOptions | None = None, + value: object | ArrayLike, limit: int | None = None, copy: bool = True, ) -> Self: @@ -1071,14 +1044,6 @@ def fillna( If a scalar value is passed it is used to fill all missing values. Alternatively, an array-like "value" can be given. It's expected that the array-like have the same length as 'self'. - method : {'backfill', 'bfill', 'pad', 'ffill', None}, default None - Method to use for filling holes in reindexed Series: - - * pad / ffill: propagate last valid observation forward to next valid. - * backfill / bfill: use NEXT valid observation to fill gap. - - .. deprecated:: 2.1.0 - limit : int, default None If method is specified, this is the maximum number of consecutive NaN values to forward/backward fill. In other words, if there is @@ -1086,9 +1051,6 @@ def fillna( be partially filled. If method is not specified, this is the maximum number of entries along the entire axis where NaNs will be filled. - - .. deprecated:: 2.1.0 - copy : bool, default True Whether to make a copy of the data before filling. If False, then the original should be modified and no new memory should be allocated. @@ -1110,16 +1072,6 @@ def fillna( [0, 0, 2, 3, 0, 0] Length: 6, dtype: Int64 """ - if method is not None: - warnings.warn( - f"The 'method' keyword in {type(self).__name__}.fillna is " - "deprecated and will be removed in a future version.", - FutureWarning, - stacklevel=find_stack_level(), - ) - - value, method = validate_fillna_kwargs(value, method) - mask = self.isna() # error: Argument 2 to "check_value_size" has incompatible type # "ExtensionArray"; expected "ndarray" @@ -1130,24 +1082,12 @@ def fillna( ) if mask.any(): - if method is not None: - meth = missing.clean_fill_method(method) - - npmask = np.asarray(mask) - if meth == "pad": - indexer = libalgos.get_fill_indexer(npmask, limit=limit) - return self.take(indexer, allow_fill=True) - else: - # i.e. meth == "backfill" - indexer = libalgos.get_fill_indexer(npmask[::-1], limit=limit)[::-1] - return self[::-1].take(indexer, allow_fill=True) + # fill with value + if not copy: + new_values = self[:] else: - # fill with value - if not copy: - new_values = self[:] - else: - new_values = self.copy() - new_values[mask] = value + new_values = self.copy() + new_values[mask] = value else: if not copy: new_values = self[:] diff --git a/pandas/core/arrays/interval.py b/pandas/core/arrays/interval.py index 1ea32584403ba..56ea28c0b50f8 100644 --- a/pandas/core/arrays/interval.py +++ b/pandas/core/arrays/interval.py @@ -29,7 +29,6 @@ ArrayLike, AxisInt, Dtype, - FillnaOptions, IntervalClosedType, NpDtype, PositionalIndexer, @@ -894,23 +893,7 @@ def max(self, *, axis: AxisInt | None = None, skipna: bool = True) -> IntervalOr indexer = obj.argsort()[-1] return obj[indexer] - def _pad_or_backfill( # pylint: disable=useless-parent-delegation - self, - *, - method: FillnaOptions, - limit: int | None = None, - limit_area: Literal["inside", "outside"] | None = None, - copy: bool = True, - ) -> Self: - # TODO(3.0): after EA.fillna 'method' deprecation is enforced, we can remove - # this method entirely. - return super()._pad_or_backfill( - method=method, limit=limit, limit_area=limit_area, copy=copy - ) - - def fillna( - self, value=None, method=None, limit: int | None = None, copy: bool = True - ) -> Self: + def fillna(self, value=None, limit: int | None = None, copy: bool = True) -> Self: """ Fill NA/NaN values using the specified method. @@ -921,9 +904,6 @@ def fillna( Alternatively, a Series or dict can be used to fill in different values for each index. The value should not be a list. The value(s) passed should be either Interval objects or NA/NaN. - method : {'backfill', 'bfill', 'pad', 'ffill', None}, default None - (Not implemented yet for IntervalArray) - Method to use for filling holes in reindexed Series limit : int, default None (Not implemented yet for IntervalArray) If method is specified, this is the maximum number of consecutive @@ -944,8 +924,6 @@ def fillna( """ if copy is False: raise NotImplementedError - if method is not None: - return super().fillna(value=value, method=method, limit=limit) value_left, value_right = self._validate_scalar(value) diff --git a/pandas/core/arrays/masked.py b/pandas/core/arrays/masked.py index 108202f5e510b..d20d7f98b8aa8 100644 --- a/pandas/core/arrays/masked.py +++ b/pandas/core/arrays/masked.py @@ -38,7 +38,6 @@ ) from pandas.errors import AbstractMethodError from pandas.util._decorators import doc -from pandas.util._validators import validate_fillna_kwargs from pandas.core.dtypes.base import ExtensionDtype from pandas.core.dtypes.common import ( @@ -237,32 +236,18 @@ def _pad_or_backfill( return new_values @doc(ExtensionArray.fillna) - def fillna( - self, value=None, method=None, limit: int | None = None, copy: bool = True - ) -> Self: - value, method = validate_fillna_kwargs(value, method) - + def fillna(self, value=None, limit: int | None = None, copy: bool = True) -> Self: mask = self._mask value = missing.check_value_size(value, mask, len(self)) if mask.any(): - if method is not None: - func = missing.get_fill_func(method, ndim=self.ndim) - npvalues = self._data.T - new_mask = mask.T - if copy: - npvalues = npvalues.copy() - new_mask = new_mask.copy() - func(npvalues, limit=limit, mask=new_mask) - return self._simple_new(npvalues.T, new_mask.T) + # fill with value + if copy: + new_values = self.copy() else: - # fill with value - if copy: - new_values = self.copy() - else: - new_values = self[:] - new_values[mask] = value + new_values = self[:] + new_values[mask] = value else: if copy: new_values = self.copy() diff --git a/pandas/core/arrays/period.py b/pandas/core/arrays/period.py index d05f857f46179..e73eba710ec39 100644 --- a/pandas/core/arrays/period.py +++ b/pandas/core/arrays/period.py @@ -847,19 +847,6 @@ def _pad_or_backfill( else: return self - def fillna( - self, value=None, method=None, limit: int | None = None, copy: bool = True - ) -> Self: - if method is not None: - # view as dt64 so we get treated as timelike in core.missing, - # similar to dtl._period_dispatch - dta = self.view("M8[ns]") - result = dta.fillna(value=value, method=method, limit=limit, copy=copy) - # error: Incompatible return value type (got "Union[ExtensionArray, - # ndarray[Any, Any]]", expected "PeriodArray") - return result.view(self.dtype) # type: ignore[return-value] - return super().fillna(value=value, method=method, limit=limit, copy=copy) - # ------------------------------------------------------------------ # Arithmetic Methods diff --git a/pandas/core/arrays/sparse/array.py b/pandas/core/arrays/sparse/array.py index bf44e5e099530..bdcb3219a9875 100644 --- a/pandas/core/arrays/sparse/array.py +++ b/pandas/core/arrays/sparse/array.py @@ -98,10 +98,7 @@ class ellipsis(Enum): from scipy.sparse import spmatrix - from pandas._typing import ( - FillnaOptions, - NumpySorter, - ) + from pandas._typing import NumpySorter SparseIndexKind = Literal["integer", "block"] @@ -717,24 +714,9 @@ def isna(self) -> Self: # type: ignore[override] mask[self.sp_index.indices] = isna(self.sp_values) return type(self)(mask, fill_value=False, dtype=dtype) - def _pad_or_backfill( # pylint: disable=useless-parent-delegation - self, - *, - method: FillnaOptions, - limit: int | None = None, - limit_area: Literal["inside", "outside"] | None = None, - copy: bool = True, - ) -> Self: - # TODO(3.0): We can remove this method once deprecation for fillna method - # keyword is enforced. - return super()._pad_or_backfill( - method=method, limit=limit, limit_area=limit_area, copy=copy - ) - def fillna( self, value=None, - method: FillnaOptions | None = None, limit: int | None = None, copy: bool = True, ) -> Self: @@ -743,17 +725,8 @@ def fillna( Parameters ---------- - value : scalar, optional - method : str, optional - - .. warning:: - - Using 'method' will result in high memory use, - as all `fill_value` methods will be converted to - an in-memory ndarray - + value : scalar limit : int, optional - copy: bool, default True Ignored for SparseArray. @@ -773,22 +746,15 @@ def fillna( When ``self.fill_value`` is not NA, the result dtype will be ``self.dtype``. Again, this preserves the amount of memory used. """ - if (method is None and value is None) or ( - method is not None and value is not None - ): - raise ValueError("Must specify one of 'method' or 'value'.") - - if method is not None: - return super().fillna(method=method, limit=limit) + if value is None: + raise ValueError("Must specify 'value'.") + new_values = np.where(isna(self.sp_values), value, self.sp_values) + if self._null_fill_value: + # This is essentially just updating the dtype. + new_dtype = SparseDtype(self.dtype.subtype, fill_value=value) else: - new_values = np.where(isna(self.sp_values), value, self.sp_values) - - if self._null_fill_value: - # This is essentially just updating the dtype. - new_dtype = SparseDtype(self.dtype.subtype, fill_value=value) - else: - new_dtype = self.dtype + new_dtype = self.dtype return self._simple_new(new_values, self._sparse_index, new_dtype) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index c0eda7f022d8f..f7607820180c3 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -99,7 +99,6 @@ check_dtype_backend, validate_ascending, validate_bool_kwarg, - validate_fillna_kwargs, validate_inclusive, ) @@ -9578,7 +9577,6 @@ def _align_series( # fill fill_na = notna(fill_value) if fill_na: - fill_value, _ = validate_fillna_kwargs(fill_value, None) left = left.fillna(fill_value) right = right.fillna(fill_value) diff --git a/pandas/core/internals/blocks.py b/pandas/core/internals/blocks.py index f6bf5dffb5f48..a7cdc7c39754d 100644 --- a/pandas/core/internals/blocks.py +++ b/pandas/core/internals/blocks.py @@ -1873,13 +1873,11 @@ def fillna( copy, refs = self._get_refs_and_copy(inplace) try: - new_values = self.values.fillna( - value=value, method=None, limit=limit, copy=copy - ) + new_values = self.values.fillna(value=value, limit=limit, copy=copy) except TypeError: # 3rd party EA that has not implemented copy keyword yet refs = None - new_values = self.values.fillna(value=value, method=None, limit=limit) + new_values = self.values.fillna(value=value, limit=limit) # issue the warning *after* retrying, in case the TypeError # was caused by an invalid fill_value warnings.warn( diff --git a/pandas/tests/arrays/categorical/test_missing.py b/pandas/tests/arrays/categorical/test_missing.py index 332d31e9e3fc2..9d4b78ce9944e 100644 --- a/pandas/tests/arrays/categorical/test_missing.py +++ b/pandas/tests/arrays/categorical/test_missing.py @@ -62,34 +62,6 @@ def test_set_item_nan(self): exp = Categorical([1, np.nan, 3], categories=[1, 2, 3]) tm.assert_categorical_equal(cat, exp) - @pytest.mark.parametrize( - "fillna_kwargs, msg", - [ - ( - {"value": 1, "method": "ffill"}, - "Cannot specify both 'value' and 'method'.", - ), - ({}, "Must specify a fill 'value' or 'method'."), - ({"method": "bad"}, "Invalid fill method. Expecting .* bad"), - ( - {"value": Series([1, 2, 3, 4, "a"])}, - "Cannot setitem on a Categorical with a new category", - ), - ], - ) - def test_fillna_raises(self, fillna_kwargs, msg): - # https://github.com/pandas-dev/pandas/issues/19682 - # https://github.com/pandas-dev/pandas/issues/13628 - cat = Categorical([1, 2, 3, None, None]) - - if len(fillna_kwargs) == 1 and "value" in fillna_kwargs: - err = TypeError - else: - err = ValueError - - with pytest.raises(err, match=msg): - cat.fillna(**fillna_kwargs) - @pytest.mark.parametrize("named", [True, False]) def test_fillna_iterable_category(self, named): # https://github.com/pandas-dev/pandas/issues/21097 diff --git a/pandas/tests/extension/conftest.py b/pandas/tests/extension/conftest.py index 5ae0864190f10..97fb5a0bc5066 100644 --- a/pandas/tests/extension/conftest.py +++ b/pandas/tests/extension/conftest.py @@ -189,7 +189,7 @@ def use_numpy(request): def fillna_method(request): """ Parametrized fixture giving method parameters 'ffill' and 'bfill' for - Series.fillna(method=) testing. + Series. testing. """ return request.param diff --git a/pandas/tests/extension/decimal/array.py b/pandas/tests/extension/decimal/array.py index 709cff59cd824..59f313b4c9edb 100644 --- a/pandas/tests/extension/decimal/array.py +++ b/pandas/tests/extension/decimal/array.py @@ -287,17 +287,10 @@ def value_counts(self, dropna: bool = True): return value_counts(self.to_numpy(), dropna=dropna) # We override fillna here to simulate a 3rd party EA that has done so. This - # lets us test the deprecation telling authors to implement _pad_or_backfill - # Simulate a 3rd-party EA that has not yet updated to include a "copy" + # lets us test a 3rd-party EA that has not yet updated to include a "copy" # keyword in its fillna method. - # error: Signature of "fillna" incompatible with supertype "ExtensionArray" - def fillna( # type: ignore[override] - self, - value=None, - method=None, - limit: int | None = None, - ): - return super().fillna(value=value, method=method, limit=limit, copy=True) + def fillna(self, value=None, limit=None): + return super().fillna(value=value, limit=limit, copy=True) def to_decimal(values, context=None): diff --git a/pandas/tests/extension/decimal/test_decimal.py b/pandas/tests/extension/decimal/test_decimal.py index bed3ec62f43da..a2721908e858f 100644 --- a/pandas/tests/extension/decimal/test_decimal.py +++ b/pandas/tests/extension/decimal/test_decimal.py @@ -137,86 +137,6 @@ def test_fillna_frame(self, data_missing): ): super().test_fillna_frame(data_missing) - def test_fillna_limit_pad(self, data_missing): - msg = "ExtensionArray.fillna 'method' keyword is deprecated" - with tm.assert_produces_warning( - DeprecationWarning, - match=msg, - check_stacklevel=False, - raise_on_extra_warnings=False, - ): - super().test_fillna_limit_pad(data_missing) - - msg = "The 'method' keyword in DecimalArray.fillna is deprecated" - with tm.assert_produces_warning( - FutureWarning, - match=msg, - check_stacklevel=False, - raise_on_extra_warnings=False, - ): - super().test_fillna_limit_pad(data_missing) - - @pytest.mark.parametrize( - "limit_area, input_ilocs, expected_ilocs", - [ - ("outside", [1, 0, 0, 0, 1], [1, 0, 0, 0, 1]), - ("outside", [1, 0, 1, 0, 1], [1, 0, 1, 0, 1]), - ("outside", [0, 1, 1, 1, 0], [0, 1, 1, 1, 1]), - ("outside", [0, 1, 0, 1, 0], [0, 1, 0, 1, 1]), - ("inside", [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]), - ("inside", [1, 0, 1, 0, 1], [1, 1, 1, 1, 1]), - ("inside", [0, 1, 1, 1, 0], [0, 1, 1, 1, 0]), - ("inside", [0, 1, 0, 1, 0], [0, 1, 1, 1, 0]), - ], - ) - def test_ffill_limit_area( - self, data_missing, limit_area, input_ilocs, expected_ilocs - ): - # GH#56616 - msg = "ExtensionArray.fillna 'method' keyword is deprecated" - with tm.assert_produces_warning( - DeprecationWarning, - match=msg, - check_stacklevel=False, - raise_on_extra_warnings=False, - ): - msg = "DecimalArray does not implement limit_area" - with pytest.raises(NotImplementedError, match=msg): - super().test_ffill_limit_area( - data_missing, limit_area, input_ilocs, expected_ilocs - ) - - def test_fillna_limit_backfill(self, data_missing): - msg = "ExtensionArray.fillna 'method' keyword is deprecated" - with tm.assert_produces_warning( - DeprecationWarning, - match=msg, - check_stacklevel=False, - raise_on_extra_warnings=False, - ): - super().test_fillna_limit_backfill(data_missing) - - msg = "The 'method' keyword in DecimalArray.fillna is deprecated" - with tm.assert_produces_warning( - FutureWarning, - match=msg, - check_stacklevel=False, - raise_on_extra_warnings=False, - ): - super().test_fillna_limit_backfill(data_missing) - - def test_fillna_no_op_returns_copy(self, data): - msg = "|".join( - [ - "ExtensionArray.fillna 'method' keyword is deprecated", - "The 'method' keyword in DecimalArray.fillna is deprecated", - ] - ) - with tm.assert_produces_warning( - (FutureWarning, DeprecationWarning), match=msg, check_stacklevel=False - ): - super().test_fillna_no_op_returns_copy(data) - def test_fillna_series(self, data_missing): msg = "ExtensionArray.fillna added a 'copy' keyword" with tm.assert_produces_warning( @@ -224,18 +144,6 @@ def test_fillna_series(self, data_missing): ): super().test_fillna_series(data_missing) - def test_fillna_series_method(self, data_missing, fillna_method): - msg = "|".join( - [ - "ExtensionArray.fillna 'method' keyword is deprecated", - "The 'method' keyword in DecimalArray.fillna is deprecated", - ] - ) - with tm.assert_produces_warning( - (FutureWarning, DeprecationWarning), match=msg, check_stacklevel=False - ): - super().test_fillna_series_method(data_missing, fillna_method) - @pytest.mark.parametrize("dropna", [True, False]) def test_value_counts(self, all_data, dropna): all_data = all_data[:10] diff --git a/pandas/tests/extension/test_arrow.py b/pandas/tests/extension/test_arrow.py index 11a9f4f22167f..9b2251d0b7d4a 100644 --- a/pandas/tests/extension/test_arrow.py +++ b/pandas/tests/extension/test_arrow.py @@ -706,10 +706,6 @@ def test_fillna_no_op_returns_copy(self, data): assert result is not data tm.assert_extension_array_equal(result, data) - result = data.fillna(method="backfill") - assert result is not data - tm.assert_extension_array_equal(result, data) - @pytest.mark.xfail( reason="GH 45419: pyarrow.ChunkedArray does not support views", run=False ) diff --git a/pandas/tests/extension/test_string.py b/pandas/tests/extension/test_string.py index c09d4d315451f..49ad3fce92a5c 100644 --- a/pandas/tests/extension/test_string.py +++ b/pandas/tests/extension/test_string.py @@ -136,10 +136,6 @@ def test_fillna_no_op_returns_copy(self, data): assert result is not data tm.assert_extension_array_equal(result, data) - result = data.fillna(method="backfill") - assert result is not data - tm.assert_extension_array_equal(result, data) - def _get_expected_exception( self, op_name: str, obj, other ) -> type[Exception] | None: