Skip to content

Commit

Permalink
Add instruction to chain with
Browse files Browse the repository at this point in the history
  • Loading branch information
TrevorWinstral committed Apr 5, 2024
1 parent 351dfd7 commit 1dc87af
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
5 changes: 3 additions & 2 deletions py-polars/polars/dataframe/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 6 additions & 4 deletions py-polars/polars/expr/datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions py-polars/polars/series/datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
18 changes: 12 additions & 6 deletions py-polars/tests/unit/datatypes/test_temporal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -640,29 +641,33 @@ 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"))

ser = df.to_series(0)
# 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")

Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 1dc87af

Please sign in to comment.