diff --git a/popcorn.py b/popcorn.py index 3b1ff34..5d945ec 100644 --- a/popcorn.py +++ b/popcorn.py @@ -227,21 +227,30 @@ def _(df_lazy: pl.LazyFrame): @app.cell def _(df_pkg_lazy: pl.LazyFrame): DISPLAY_TOP = 20 - df_top_pkg_dl = ( - df_pkg_lazy.group_by("package") - .agg(pl.col("downloads").sum()) - .sort("downloads", descending=True) - .head(DISPLAY_TOP) - .collect() - ) + df_pkg_dl = df_pkg_lazy.group_by("package").agg(pl.col("downloads").sum()).collect() - ( - lp.ggplot(df_top_pkg_dl, lp.aes("package", "downloads")) - + lp.geom_bar(stat="identity") - + lp.labs( - title="Top packages", - caption="Daily number of unique providers for package update statistics opting in to popcorn.", - ) + lp.gggrid( + [ + lp.ggplot( + df_pkg_dl.sort("downloads", descending=True).head(DISPLAY_TOP), + lp.aes("package", "downloads"), + ) + + lp.geom_bar(stat="identity") + + lp.labs( + title="Top packages", + caption="Most updated packages over all time", + ), + lp.ggplot( + df_pkg_dl.sort("downloads", descending=False).head(DISPLAY_TOP), + lp.aes("package", "downloads"), + ) + + lp.geom_bar(stat="identity") + + lp.labs( + title="Rarest packages", + caption="Least updated packages over all time", + ), + ], + ncol=1, ) return