Skip to content

Commit

Permalink
docs: Update group_by_dynamic example
Browse files Browse the repository at this point in the history
  • Loading branch information
stinodego committed Oct 14, 2023
1 parent 55c9f8f commit e739d13
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
16 changes: 5 additions & 11 deletions docs/src/python/user-guide/transformations/time-series/rolling.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
) + lit(1))
.alias("days_in_month"),
])
.explode([col("day/eom")])
.collect()?;
println!("{}", &out);
// --8<-- [end:group_by_dyn]
Expand Down

0 comments on commit e739d13

Please sign in to comment.