From c000fdec21c9c509d12c87735e1402e8319498f6 Mon Sep 17 00:00:00 2001 From: PulkoMandy Date: Sat, 1 Jan 2022 12:45:13 +0100 Subject: [PATCH] Remove authors with 0 commits from author of the year/month Fixes #215 --- analysis/gitrepository.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/analysis/gitrepository.py b/analysis/gitrepository.py index 1729871..5296693 100644 --- a/analysis/gitrepository.py +++ b/analysis/gitrepository.py @@ -189,7 +189,7 @@ def get_authors_ranking_by_year(self): # then sort each group res = ts_agg.apply(lambda x: x.sort_values(ascending=False)) - return res + return res[res > 0] def get_authors_ranking_by_month(self): """ @@ -207,11 +207,12 @@ def get_authors_ranking_by_month(self): .dt.strftime('%Y-%m')}) # https://stackoverflow.com/questions/27842613/pandas-groupby-sort-within-groups - ts_agg = df.groupby([df.timestamp, df.author_name]).size()\ - .groupby(level=0, group_keys=False) + ts_agg = df.groupby([df.timestamp, df.author_name]).size() + ts_agg = ts_agg.groupby(level=0, group_keys=False) # sort each group by value - return ts_agg.apply(lambda x: x.sort_values(ascending=False)) + res = ts_agg.apply(lambda x: x.sort_values(ascending=False)) + return res[res > 0] @property def authors(self) -> GitAuthors: