Skip to content

Commit

Permalink
Fix compatibility with Pandas 2.x
Browse files Browse the repository at this point in the history
is_merge_commit with bool type cannot be used in a sum() operation.
Anyway it was converted to int32 just a few lines later.
  • Loading branch information
pulkomandy committed Sep 14, 2024
1 parent 342475c commit 71037b9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion analysis/gitauthors.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@ def __init__(self, git_history: pd.DataFrame):
'deletions']].copy()
self.raw_authors_data['author_datetime'] = pd.to_datetime(git_history['author_timestamp'], unit='s', utc=True)

# Convert is_merge_commit to int32 so it can be summed
self.raw_authors_data['is_merge_commit'] = self.raw_authors_data['is_merge_commit'].astype('int32')

authors_grouped = self.raw_authors_data[['author_name', 'author_datetime',
'insertions', 'deletions', 'is_merge_commit']].groupby(
[self.raw_authors_data['author_name']])


self.authors_summary = authors_grouped.sum(numeric_only=True)
self.authors_summary['first_commit_date'] = authors_grouped['author_datetime'].min()
self.authors_summary['latest_commit_date'] = authors_grouped['author_datetime'].max()
Expand All @@ -24,7 +29,6 @@ def __init__(self, git_history: pd.DataFrame):
self.authors_summary['contributed_days_count'].replace(0, 1, inplace=True)
self.authors_summary['commits_count'] = authors_grouped['author_name'].count()
self.authors_summary.rename(columns={'is_merge_commit': 'merge_commits_count'}, inplace=True)
self.authors_summary['merge_commits_count'] = self.authors_summary['merge_commits_count'].astype('int32')
self.authors_summary.reset_index(inplace=True)

def count(self):
Expand Down

0 comments on commit 71037b9

Please sign in to comment.