Add weekday barplot

This commit is contained in:
Marty Oehme 2025-09-28 21:05:44 +02:00
parent 343b75c9e4
commit 07c45ca205
Signed by: Marty
GPG key ID: 4E535BC19C61886E

View file

@ -129,20 +129,58 @@ def _():
@app.cell
def _(df: pl.DataFrame):
weekly_downloads = (
df.sort("date")
.group_by_dynamic("date", every="1w")
.agg(pl.col("downloads").sum())
.sort("date")
)
(
lp.ggplot(weekly_downloads, lp.aes("date", "downloads"))
+ lp.geom_line()
+ lp.geom_smooth(method="loess")
+ lp.labs(
title="Weekly downloads",
def _():
weekly_downloads = (
df.sort("date")
.group_by_dynamic("date", every="1w")
.agg(pl.col("downloads").sum())
.sort("date")
)
)
return (
lp.ggplot(weekly_downloads, lp.aes("date", "downloads"))
+ lp.geom_line()
+ lp.geom_smooth(method="loess")
+ lp.labs(
title="Weekly downloads",
)
)
_()
return
@app.cell
def _(df: pl.DataFrame):
def _():
weekday_downloads = df.sort("date").with_columns(
pl.col("date")
.dt.weekday()
.sort()
.replace_strict(
{
1: "Mon",
2: "Tue",
3: "Wed",
4: "Thu",
5: "Fri",
6: "Sat",
7: "Sun",
}
)
.alias("weekday")
)
return (
lp.ggplot(weekday_downloads, lp.aes("weekday", "downloads"))
+ lp.geom_bar()
+ lp.labs(
title="Weekday downloads",
caption="Downloads aggregated per day of the week they took place.",
)
)
_()
return
@ -193,7 +231,6 @@ def _(sizes_df):
# further ideas:
#
# - daily download habits:
# - which weekday has most downloads?
# - are we downloading further spread of versions on specific days
# - are there 'update' days, where things converge? specific weekday/on holidays/etc?
#