Add Window Functions in Polars notebook#103
Conversation
| # "polars==1.29.0", | ||
| # "pyarrow==20.0.0", | ||
| # "sqlglot==26.16.4", | ||
| # ] |
There was a problem hiding this comment.
Requires duckdb, pyarrow and sqlglot to execute the SQL cell present
| def _(df, pl): | ||
| ( | ||
| df.with_columns( | ||
| is_weekday=pl.col("date").dt.is_business_day(), |
There was a problem hiding this comment.
FYI that is_business_day was added after Polars 1.24.0, which is currently the latest version available in WASM.
Happy to update if this is an issue.
There was a problem hiding this comment.
Great work on this notebook contrib! Really great walkthrough of the topic at hand & clear progression through window functions concepts & the examples build well on each other. The dataset is simple and the explanations are easy to follow and relevant to chosen data.
One tiny naming nit/doubt I have: in the window reuse example, I wonder if cumulative_daily_revenue might be slightly misleading since it's actually cumulative revenue of each day (across channels) rather than across days.
The SQL cell inclusion and mapping strategies sections are particularly helpful. Thanks again for a great contrib ❤️
PS: I was crosschecking and playing around with mo.ui.dataframe and passing the polars queries inside it & applying transformations via the UI to cross-check the cell outputs 😄
|
Hi @Haleshot, Thanks very much for the positive feedback, the quick review and merge!
Thinking about it more, this was really the only metric / calculation that didn't make much sense. I.e., it doesn't make much sense to cumulate across channel as there is no natural order (compared to cumulating across dates). I removed it given there are 3 new columns re-using the same window, enough to support what is being shown! Thanks again! |
📝 Summary
The PR adds the Window Functions notebook in the Polars course.
It covers:
Relates to: #40
I welcome any feedback or suggestions!
📋 Checklist
--sandboxREADME.md