summaryrefslogtreecommitdiff
path: root/megapixels/commands/msc
diff options
context:
space:
mode:
Diffstat (limited to 'megapixels/commands/msc')
-rw-r--r--megapixels/commands/msc/summarize.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/megapixels/commands/msc/summarize.py b/megapixels/commands/msc/summarize.py
index 045e3b69..762cddc2 100644
--- a/megapixels/commands/msc/summarize.py
+++ b/megapixels/commands/msc/summarize.py
@@ -43,6 +43,18 @@ def cli(ctx, opt_fp_in, opt_fp_out):
df.to_csv(fp_out, index=False)
+ # Print outputs by year
+ results_year = []
+ year_groups = df.groupby('year')
+ for year, group in year_groups:
+ if int(year) > 0:
+ results_year.append({'year': year, 'count': len(group)})
+
+ fp_out = opt_fp_out.replace('.csv', '_years.csv')
+ df_years = pd.DataFrame.from_dict(results_year)
+ df_years.to_csv(fp_out, index=False)
+ pprint(df_years)
+
# create country summary
fp_out = opt_fp_out.replace('.csv', '_countries.csv')
country_groups = df.groupby('country')