Add weekday barplot
This commit is contained in:
parent
343b75c9e4
commit
07c45ca205
1 changed files with 51 additions and 14 deletions
65
popcorn.py
65
popcorn.py
|
|
@ -129,20 +129,58 @@ def _():
|
||||||
|
|
||||||
@app.cell
|
@app.cell
|
||||||
def _(df: pl.DataFrame):
|
def _(df: pl.DataFrame):
|
||||||
weekly_downloads = (
|
def _():
|
||||||
df.sort("date")
|
weekly_downloads = (
|
||||||
.group_by_dynamic("date", every="1w")
|
df.sort("date")
|
||||||
.agg(pl.col("downloads").sum())
|
.group_by_dynamic("date", every="1w")
|
||||||
.sort("date")
|
.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",
|
|
||||||
)
|
)
|
||||||
)
|
|
||||||
|
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
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -193,7 +231,6 @@ def _(sizes_df):
|
||||||
# further ideas:
|
# further ideas:
|
||||||
#
|
#
|
||||||
# - daily download habits:
|
# - daily download habits:
|
||||||
# - which weekday has most downloads?
|
|
||||||
# - are we downloading further spread of versions on specific days
|
# - are we downloading further spread of versions on specific days
|
||||||
# - are there 'update' days, where things converge? specific weekday/on holidays/etc?
|
# - are there 'update' days, where things converge? specific weekday/on holidays/etc?
|
||||||
#
|
#
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue