Skip to content

Commit

Permalink
fix python groupby_dynamic doc
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Dec 18, 2021
1 parent 02e4e24 commit 8ed0c0c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions py-polars/polars/internals/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -2350,6 +2350,7 @@ def groupby_dynamic(
└─────────────────────┴─────┘
Group by windows of 1 hour starting at 2021-12-16 00:00:00.
>>> (
... df.groupby_dynamic("time", every="1h").agg(
... [pl.col("time").min(), pl.col("time").max()]
Expand All @@ -2369,6 +2370,7 @@ def groupby_dynamic(
└─────────────────────┴─────────────────────┴─────────────────────┘
The window boundaries can also be added to the aggregation result
>>> (
... df.groupby_dynamic("time", every="1h", include_boundaries=True).agg(
... [pl.col("time").count()]
Expand All @@ -2388,6 +2390,7 @@ def groupby_dynamic(
└─────────────────────┴─────────────────────┴─────────────────────┴────────────┘
When closed="left", should not include right end of interval [lower_bound, upper_bound)
>>> (
... df.groupby_dynamic("time", every="1h", closed="left").agg(
... [pl.col("time").count(), pl.col("time").list()]
Expand All @@ -2407,6 +2410,7 @@ def groupby_dynamic(
└─────────────────────┴────────────┴─────────────────────────────────────┘
When closed="both" the time values at the window boundaries belong to 2 groups.
>>> (
... df.groupby_dynamic("time", every="1h", closed="both").agg(
... [pl.col("time").count()]
Expand All @@ -2426,6 +2430,7 @@ def groupby_dynamic(
└─────────────────────┴────────────┘
Dynamic groupbys can also be combined with grouping on normal keys
>>> df = pl.DataFrame(
... {
... "time": pl.date_range(
Expand Down

0 comments on commit 8ed0c0c

Please sign in to comment.