From efa08b4b547c894e5ce6f3aafee76e5cff91ada4 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Sun, 28 Sep 2025 21:11:14 +0200 Subject: [PATCH] Add monthwise downloads barplot --- popcorn.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/popcorn.py b/popcorn.py index 7a65155..9ed2235 100644 --- a/popcorn.py +++ b/popcorn.py @@ -122,7 +122,6 @@ def _(): .fill_null(0) .unpivot(index="date", variable_name="package", value_name="downloads") ) - df_lazy return @@ -144,6 +143,7 @@ def _(df_lazy: pl.LazyFrame): title="Weekly downloads", ) ) + _() return @@ -181,6 +181,27 @@ def _(df_lazy: pl.LazyFrame): caption="Downloads aggregated per day of the week they took place.", ) ) + + _() + return + + +@app.cell +def _(df_lazy: pl.LazyFrame): + def _(): + month_agg_downloads = ( + df_lazy.sort("date") + .with_columns(pl.col("date").dt.month().alias("month")) + .collect() + ) + return ( + lp.ggplot(month_agg_downloads, lp.aes("month", "downloads")) + + lp.geom_bar() + + lp.labs( + title="Monthwise downloads", + caption="Downloads aggregated per month of the year.", + ) + ) _() return