From e739d13a5bee3c509f7514a94a97e33d2db2fade Mon Sep 17 00:00:00 2001 From: Stijn de Gooijer Date: Sat, 14 Oct 2023 20:05:59 +0200 Subject: [PATCH 1/2] docs: Update `group_by_dynamic` example --- .../transformations/time-series/rolling.py | 16 +++++----------- .../transformations/time-series/rolling.rs | 1 - 2 files changed, 5 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] From 041f747b14359171a17fcdee9aae4b50ba79c166 Mon Sep 17 00:00:00 2001 From: Stijn de Gooijer Date: Sat, 14 Oct 2023 20:06:59 +0200 Subject: [PATCH 2/2] Add cot docs --- py-polars/docs/source/reference/expressions/computation.rst | 1 + py-polars/docs/source/reference/series/computation.rst | 1 + 2 files changed, 2 insertions(+) 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