diff options
| author | Adam Harvey <adam@ahprojects.com> | 2019-06-05 09:49:42 -0500 |
|---|---|---|
| committer | Adam Harvey <adam@ahprojects.com> | 2019-06-05 09:49:42 -0500 |
| commit | 11d0839a209342cb6c0d511a4ae6a5a7026c9df9 (patch) | |
| tree | 6dc12fb6da753bb6eb4e0ec7af1df6986a28be99 /megapixels/commands/msc | |
| parent | b42229140c0a5c52f916b79d43813ab3fe5493cc (diff) | |
add year sum
Diffstat (limited to 'megapixels/commands/msc')
| -rw-r--r-- | megapixels/commands/msc/summarize.py | 12 |
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') |
