Created
January 23, 2022 15:49
-
-
Save jboynyc/3c87aa2e1ba2c8df6d2cbfb43acfb1bf to your computer and use it in GitHub Desktop.
Create a bar chart showing monthly commits to a Git repository over time
This file contains 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 altair as alt | |
import pandas as pd | |
from pydriller import Repository | |
repo_dates = [] | |
for commit in Repository('/path/to/repository').traverse_commits(): | |
repo_dates.append(commit.committer_date) | |
d = pd.DataFrame(dict(commit_date=pd.to_datetime(repo_dates, utc=True), commits=1)) | |
r = d.set_index("commit_date").resample("1m").count() | |
alt.Chart(r.reset_index()).mark_bar(color="blue").encode( | |
x='yearmonth(commit_date):O', | |
y='commits:Q' | |
).properties(width=600) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment