From 1dc87af55e26fd6bdac09c3141fa9288a909f4b4 Mon Sep 17 00:00:00 2001 From: TrevorWinstral Date: Fri, 5 Apr 2024 09:41:28 +0200 Subject: [PATCH] Add instruction to chain with --- py-polars/polars/dataframe/frame.py | 5 +++-- py-polars/polars/expr/datetime.py | 10 ++++++---- py-polars/polars/series/datetime.py | 4 ++-- .../tests/unit/datatypes/test_temporal.py | 18 ++++++++++++------ 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/py-polars/polars/dataframe/frame.py b/py-polars/polars/dataframe/frame.py index fc59e80e6f63..58ef488eaf41 100644 --- a/py-polars/polars/dataframe/frame.py +++ b/py-polars/polars/dataframe/frame.py @@ -5937,7 +5937,7 @@ def upsample( .. deprecated:: 0.20.19 This argument is deprecated and will be removed in the next breaking - release. + release. Instead, chain `upsample` with `.dt.offset`. group_by First group by these columns and then upsample for every group. maintain_order @@ -5987,7 +5987,8 @@ def upsample( every = deprecate_saturating(every) if offset is not None: issue_deprecation_warning( - "`offset` is deprecated and will be removed in the next breaking release.", + "`offset` is deprecated and will be removed in the next breaking release. " + "Instead, chain `upsample` with `.dt.offset`.", version="0.20.19", ) offset = deprecate_saturating(offset) diff --git a/py-polars/polars/expr/datetime.py b/py-polars/polars/expr/datetime.py index 8da4aeb9814b..3c91e01f4d28 100644 --- a/py-polars/polars/expr/datetime.py +++ b/py-polars/polars/expr/datetime.py @@ -60,7 +60,7 @@ def truncate( .. deprecated:: 0.20.19 This argument is deprecated and will be removed in the next breaking - release. + release. Instead, chain `dt.truncate()` with `.dt.offset()`. use_earliest Determine how to deal with ambiguous datetimes: @@ -188,7 +188,8 @@ def truncate( offset = deprecate_saturating(offset) if offset is not None: issue_deprecation_warning( - "`offset` is deprecated and will be removed in the next breaking release.", + "`offset` is deprecated and will be removed in the next breaking release. " + "Instead, chain `dt.truncate` with `.dt.offset`.", version="0.20.19", ) if not isinstance(every, pl.Expr): @@ -249,7 +250,7 @@ def round( .. deprecated:: 0.20.19 This argument is deprecated and will be removed in the next breaking - release. + release. Instead, chain `dt.round` with `.dt.offset`. ambiguous Determine how to deal with ambiguous datetimes: @@ -344,7 +345,8 @@ def round( offset = deprecate_saturating(offset) if offset is not None: issue_deprecation_warning( - "`offset` is deprecated and will be removed in the next breaking release.", + "`offset` is deprecated and will be removed in the next breaking release. " + "Instead, chain `dt.round` with `.dt.offset`.", version="0.20.19", ) if offset is None: diff --git a/py-polars/polars/series/datetime.py b/py-polars/polars/series/datetime.py index 46f82581499d..137d8445eb5c 100644 --- a/py-polars/polars/series/datetime.py +++ b/py-polars/polars/series/datetime.py @@ -1592,7 +1592,7 @@ def truncate( .. deprecated:: 0.20.19 This argument is deprecated and will be removed in the next breaking - release. + release. Instead, chain `dt.truncate` with `.dt.offset`. use_earliest Determine how to deal with ambiguous datetimes: @@ -1743,7 +1743,7 @@ def round( .. deprecated:: 0.20.19 This argument is deprecated and will be removed in the next breaking - release. + release. Instead, chain `dt.round` with `.dt.offset`. ambiguous Determine how to deal with ambiguous datetimes: diff --git a/py-polars/tests/unit/datatypes/test_temporal.py b/py-polars/tests/unit/datatypes/test_temporal.py index 2ff8fb96d735..ff78b5ea6106 100644 --- a/py-polars/tests/unit/datatypes/test_temporal.py +++ b/py-polars/tests/unit/datatypes/test_temporal.py @@ -627,7 +627,8 @@ def test_offset_deprecated() -> None: # upsample with pytest.warns( DeprecationWarning, - match="`offset` is deprecated and will be removed in the next breaking release.", + match="`offset` is deprecated and will be removed in the next breaking release. " + "Instead, chain `upsample` with `.dt.offset`.", ): df.upsample( time_column="time", @@ -640,14 +641,16 @@ def test_offset_deprecated() -> None: # truncate with pytest.warns( DeprecationWarning, - match="`offset` is deprecated and will be removed in the next breaking release.", + match="`offset` is deprecated and will be removed in the next breaking release. " + "Instead, chain `dt.truncate` with `.dt.offset`.", ): df.select(pl.col("time").dt.truncate(every="1mo", offset="1d")) # round with pytest.warns( DeprecationWarning, - match="`offset` is deprecated and will be removed in the next breaking release.", + match="`offset` is deprecated and will be removed in the next breaking release. " + "Instead, chain `dt.round` with `.dt.offset`.", ): df.select(pl.col("time").dt.round(every="1mo", offset="1d")) @@ -655,14 +658,16 @@ def test_offset_deprecated() -> None: # truncate with pytest.warns( DeprecationWarning, - match="`offset` is deprecated and will be removed in the next breaking release.", + match="`offset` is deprecated and will be removed in the next breaking release. " + "Instead, chain `dt.truncate` with `.dt.offset`.", ): ser.dt.truncate(every="1mo", offset="1d") # round with pytest.warns( DeprecationWarning, - match="`offset` is deprecated and will be removed in the next breaking release.", + match="`offset` is deprecated and will be removed in the next breaking release. " + "Instead, chain `dt.round` with `.dt.offset`.", ): ser.dt.round(every="1mo", offset="1d") @@ -699,7 +704,8 @@ def test_upsample_crossing_dst( if offset is not None: with pytest.warns( DeprecationWarning, - match="`offset` is deprecated and will be removed in the next breaking release.", + match="`offset` is deprecated and will be removed in the next breaking release. " + "Instead, chain `upsample` with `.dt.offset`.", ): result = df.upsample(time_column="time", every="1d", offset=offset) else: