Created
August 17, 2021 17:22
-
-
Save zmitry/1e31202914aed6d33b7b827e039cd670 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pygal | |
| import pandas as pd | |
| import csv | |
| result = [] | |
| with open('./log.csv', 'r', newline='') as csvfile: | |
| reader = csv.DictReader(csvfile) | |
| for row in reader: | |
| record = { | |
| "count": int(row["count"]), | |
| "file": row["file"] | |
| } | |
| result.append(record) | |
| treshold=15 | |
| sorted(result, key=lambda r: r["count"], reverse=True) | |
| line_chart = pygal.Bar(width=2000, height=1500,legend_at_bottom=True,legend_at_bottom_columns=2) | |
| line_chart.title = 'File changes' | |
| touched_count=0; | |
| for res in result: | |
| if res["count"] > treshold: | |
| touched_count+=1 | |
| line_chart.add(res["file"], res["count"]) | |
| print(f'top:{touched_count}, total:{len(result)}') | |
| line_chart.render_to_file('bar_chart.svg') | |
| df = pd.DataFrame(result, columns=["count", "file"]) | |
| df['count'] = df['count'].astype(int) | |
| line_chart = pygal.StackedBar() | |
| line_chart.title = f'Amount of commits per most frequently changed files(more than {treshold} changes for last year) vs regular(less than {treshold})' | |
| line_chart.x_labels = [f"more than {treshold} changes per file", f"less than {treshold} changes per file"] | |
| line_chart.add('Amount of files', [df[df['count'] >= treshold].count()["count"], df[df['count'] < treshold].count()["count"]]) | |
| line_chart.add('Commits', [df[df['count'] >= treshold].sum()["count"], df[df['count'] < treshold].sum()["count"]]) | |
| line_chart.render_to_file('distribution.svg') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment