Created
July 9, 2021 18:54
-
-
Save Padhma/0e7a0b7cbbf88ce8276e6596ffe993f6 to your computer and use it in GitHub Desktop.
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
# converting Star, Fork and Watch columns to numeric by replacing 'k' with 1000 | |
github_df['Star'] = github_df['Star'].apply(lambda x: float(x.rstrip('k'))*1000 if x.endswith('k') else float(x)) | |
github_df['Fork'] = github_df['Fork'].apply(lambda x: float(x.rstrip('k'))*1000 if x.endswith('k') else float(x)) | |
github_df['Watch'] = github_df['Watch'].apply(lambda x: float(x.rstrip('k'))*1000 if 'k' in x else float(x)) | |
# Remove , from issue and commits | |
github_df['Issues'] = github_df['Issues'].apply(lambda x: x.replace(',','')) | |
github_df['Commits'] = github_df['Commits'].apply(lambda x: x.replace(',','')) | |
# Convert multiple object columns to numeric | |
cols = ['Issues','Pull_Requests','Commits','Contributors'] | |
github_df[cols] = github_df[cols].apply(pd.to_numeric, errors='coerce', axis=1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment