diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2019-06-06 11:03:56 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2019-06-06 11:03:56 +0200 |
| commit | 502dc0a961bd0b0680522f4dc383034983e88a64 (patch) | |
| tree | 1519189a230f923e36f4cca72787665ad9eb6352 /megapixels/commands/msc/summarize.py | |
| parent | 0388dca71c5ad20f936125549fe95918c5fe7544 (diff) | |
| parent | fe066d0b79a305731e9ad7286445f17073ef917d (diff) | |
Merge branch 'master' of github.com:adamhrv/megapixels_dev
Diffstat (limited to 'megapixels/commands/msc/summarize.py')
| -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') |
