diff --git a/doc/whats-new.rst b/doc/whats-new.rst index 157282803cc..430da3e4c4e 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -47,6 +47,9 @@ Deprecations existing methods work and don't raise any warnings, given the relatively small benefits of the change. By `Maximilian Roos `_. +- Finally remove ``keep_attrs`` kwarg from :py:meth:`DataArray.resample` and + :py:meth:`Dataset.resample`. These were deprecated a long time ago. + By `Deepak Cherian `_. Bug fixes ~~~~~~~~~ diff --git a/xarray/core/common.py b/xarray/core/common.py index fef8adb101a..fa0fa9aec0f 100644 --- a/xarray/core/common.py +++ b/xarray/core/common.py @@ -860,7 +860,6 @@ def _resample( base: int | None, offset: pd.Timedelta | datetime.timedelta | str | None, origin: str | DatetimeLike, - keep_attrs: bool | None, loffset: datetime.timedelta | str | None, restore_coord_dims: bool | None, **indexer_kwargs: str, @@ -989,13 +988,6 @@ def _resample( from xarray.core.pdcompat import _convert_base_to_offset from xarray.core.resample import RESAMPLE_DIM - if keep_attrs is not None: - warnings.warn( - "Passing ``keep_attrs`` to ``resample`` has no effect and will raise an" - " error in xarray 0.20. Pass ``keep_attrs`` directly to the applied" - " function, e.g. ``resample(...).mean(keep_attrs=True)``." - ) - # note: the second argument (now 'skipna') use to be 'dim' if ( (skipna is not None and not isinstance(skipna, bool)) diff --git a/xarray/core/dataarray.py b/xarray/core/dataarray.py index c512e742fb8..27eb3cdfddc 100644 --- a/xarray/core/dataarray.py +++ b/xarray/core/dataarray.py @@ -7021,7 +7021,6 @@ def resample( base: int | None = None, offset: pd.Timedelta | datetime.timedelta | str | None = None, origin: str | DatetimeLike = "start_day", - keep_attrs: bool | None = None, loffset: datetime.timedelta | str | None = None, restore_coord_dims: bool | None = None, **indexer_kwargs: str, @@ -7143,7 +7142,6 @@ def resample( base=base, offset=offset, origin=origin, - keep_attrs=keep_attrs, loffset=loffset, restore_coord_dims=restore_coord_dims, **indexer_kwargs, diff --git a/xarray/core/dataset.py b/xarray/core/dataset.py index da13d52b9c1..c7f92b87d63 100644 --- a/xarray/core/dataset.py +++ b/xarray/core/dataset.py @@ -10327,7 +10327,6 @@ def resample( base: int | None = None, offset: pd.Timedelta | datetime.timedelta | str | None = None, origin: str | DatetimeLike = "start_day", - keep_attrs: bool | None = None, loffset: datetime.timedelta | str | None = None, restore_coord_dims: bool | None = None, **indexer_kwargs: str, @@ -10404,7 +10403,6 @@ def resample( base=base, offset=offset, origin=origin, - keep_attrs=keep_attrs, loffset=loffset, restore_coord_dims=restore_coord_dims, **indexer_kwargs, diff --git a/xarray/tests/test_groupby.py b/xarray/tests/test_groupby.py index 8afdf95a082..4974394d59a 100644 --- a/xarray/tests/test_groupby.py +++ b/xarray/tests/test_groupby.py @@ -1776,11 +1776,6 @@ def test_resample_keep_attrs(self): expected = DataArray([1, 1, 1], [("time", times[::4])], attrs=array.attrs) assert_identical(result, expected) - with pytest.warns( - UserWarning, match="Passing ``keep_attrs`` to ``resample`` has no effect." - ): - array.resample(time="1D", keep_attrs=True) - def test_resample_skipna(self): times = pd.date_range("2000-01-01", freq="6H", periods=10) array = DataArray(np.ones(10), [("time", times)]) @@ -2138,11 +2133,6 @@ def test_resample_by_mean_with_keep_attrs(self): expected = ds.attrs assert expected == actual - with pytest.warns( - UserWarning, match="Passing ``keep_attrs`` to ``resample`` has no effect." - ): - ds.resample(time="1D", keep_attrs=True) - def test_resample_loffset(self): times = pd.date_range("2000-01-01", freq="6H", periods=10) ds = Dataset(