From 95b4480690b40e21c886433167b968573e5feca7 Mon Sep 17 00:00:00 2001 From: Stijn de Gooijer Date: Sat, 14 Oct 2023 20:25:13 +0200 Subject: [PATCH] docs: Update group_by_dynamic example (#11737) --- .../transformations/time-series/rolling.py | 16 +++++----------- .../transformations/time-series/rolling.rs | 1 - .../source/reference/expressions/computation.rst | 1 + .../docs/source/reference/series/computation.rst | 1 + 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/docs/src/python/user-guide/transformations/time-series/rolling.py b/docs/src/python/user-guide/transformations/time-series/rolling.py index 16f751523ade..f41d2a48c05e 100644 --- a/docs/src/python/user-guide/transformations/time-series/rolling.py +++ b/docs/src/python/user-guide/transformations/time-series/rolling.py @@ -29,17 +29,11 @@ .to_frame() ) -out = ( - df.group_by_dynamic("time", every="1mo", period="1mo", closed="left") - .agg( - [ - pl.col("time").cumcount().reverse().head(3).alias("day/eom"), - ((pl.col("time") - pl.col("time").first()).last().dt.days() + 1).alias( - "days_in_month" - ), - ] - ) - .explode("day/eom") +out = df.group_by_dynamic("time", every="1mo", period="1mo", closed="left").agg( + pl.col("time").cumcount().reverse().head(3).alias("day/eom"), + ((pl.col("time") - pl.col("time").first()).last().dt.days() + 1).alias( + "days_in_month" + ), ) print(out) # --8<-- [end:group_by_dyn] diff --git a/docs/src/rust/user-guide/transformations/time-series/rolling.rs b/docs/src/rust/user-guide/transformations/time-series/rolling.rs index 6458eb69bdfc..0528d536d718 100644 --- a/docs/src/rust/user-guide/transformations/time-series/rolling.rs +++ b/docs/src/rust/user-guide/transformations/time-series/rolling.rs @@ -86,7 +86,6 @@ fn main() -> Result<(), Box> { ) + lit(1)) .alias("days_in_month"), ]) - .explode([col("day/eom")]) .collect()?; println!("{}", &out); // --8<-- [end:group_by_dyn] diff --git a/py-polars/docs/source/reference/expressions/computation.rst b/py-polars/docs/source/reference/expressions/computation.rst index 298631c7dfdf..464163406b80 100644 --- a/py-polars/docs/source/reference/expressions/computation.rst +++ b/py-polars/docs/source/reference/expressions/computation.rst @@ -18,6 +18,7 @@ Computation Expr.cbrt Expr.cos Expr.cosh + Expr.cot Expr.cumcount Expr.cummax Expr.cummin diff --git a/py-polars/docs/source/reference/series/computation.rst b/py-polars/docs/source/reference/series/computation.rst index 776fcf510f84..4757fc761661 100644 --- a/py-polars/docs/source/reference/series/computation.rst +++ b/py-polars/docs/source/reference/series/computation.rst @@ -18,6 +18,7 @@ Computation Series.cbrt Series.cos Series.cosh + Series.cot Series.cummax Series.cummin Series.cumprod