<jupyter_start><jupyter_text>SlimGroup GitHub InsightsIn this notebook, we look at some traffic and contribution insight for our repositories.   Import libraries and dataI'll import the necessary libraries as I'll use the **seaborn** library to plot the insights.<jupyter_code>import pandas as pd
import matplotlib
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
font = {'family' : 'normal',
        'size'   : 20}

matplotlib.rc('font', **font)
repos = pd.read_csv('repos_info.csv')
commits = pd.read_csv('commits_info.csv')<jupyter_output><empty_output><jupyter_text>Basic AnalysisLet's begin by exploring the repos and commit datasets. Then, I'll check the repos on the basis of forks, stars and watchers. Finally, I'll check the commit messages.<jupyter_code>print("Total repos till date: {}".format(repos.shape[0]))
print("Total commits till date: {}".format(commits.shape[0]))
repos
repos.describe()<jupyter_output><empty_output><jupyter_text>Clones and views<jupyter_code>repo_views = repos.nlargest(10, 'Views')
plt.figure(figsize = (20, 12))
sns.barplot(repo_views['Name'], repo_views['Views'])
plt.xticks(rotation = 90)
plt.xlabel("Repository", fontsize = 20)
plt.ylabel("Viewers", fontsize = 20)
plt.title("Unique viewers per repository", fontsize = 20)
repo_clones = repos.nlargest(10, 'Clones')

plt.figure(figsize = (20, 12))
sns.barplot(repo_clones['Name'], repo_clones['Clones'])
plt.xticks(rotation = 90)
plt.xlabel("Repository", fontsize = 20)
plt.ylabel("Clones", fontsize = 20)
plt.title("Unique clones per repository", fontsize = 20)<jupyter_output>/home/mlouboutin3/GATechBundle/Miniconda3/lib/python3.8/site-packages/seaborn/_decorators.py:36: FutureWarning: Pass the following variables as keyword args: x, y. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation.
  warnings.warn(<jupyter_text>Commits per repository<jupyter_code>commits_count = pd.DataFrame(pd.merge(repos, 
         commits, 
         left_on='Id', 
         right_on='Repo Id', 
         how = 'left').groupby('Id').size().reset_index())
commits_count.columns = ['Id', 'Commits count']
repos = pd.merge(repos, commits_count, on = 'Id')
plt.figure(figsize = (20, 12))
sns.barplot(repos['Name'], repos['Commits count'])
plt.xticks(rotation = 90)
plt.xlabel("Repository", fontsize = 20)
plt.ylabel("Commits", fontsize = 20)
plt.title("Commits per repository", fontsize = 20)<jupyter_output>/home/mlouboutin3/GATechBundle/Miniconda3/lib/python3.8/site-packages/seaborn/_decorators.py:36: FutureWarning: Pass the following variables as keyword args: x, y. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation.
  warnings.warn(<jupyter_text>Yearly analysis<jupyter_code>commits['Year'] = commits['Date'].apply(lambda x: x.split('-')[0])
yearly_stats = commits.groupby('Year').count()['Commit Id']
plt.figure(figsize = (20, 12))
sns.barplot(yearly_stats.index, yearly_stats.values)
plt.xlabel("Year", fontsize = 20)
plt.ylabel("Commits", fontsize = 20)
plt.title("Commits in each year", fontsize = 20)<jupyter_output>/home/mlouboutin3/GATechBundle/Miniconda3/lib/python3.8/site-packages/seaborn/_decorators.py:36: FutureWarning: Pass the following variables as keyword args: x, y. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation.
  warnings.warn(<jupyter_text>Monthly commits in 2021<jupyter_code>commits['Month'] = commits['Date'].apply(lambda x: x.split('-')[1])
monthly_stats = commits[commits['Year'] == '2021'].groupby('Month').count()['Commit Id']
month_mapper = { '01': 'January', '02': 'February', '03': 'March', '04': 'April', '05': 'May', '06': 'June', '07': 'July', '08': 'August', 
                '09': 'September', '10': 'October', '11': 'November', '12': 'December'}
labels = []
for value in monthly_stats.index:
    labels.append(month_mapper[value])

plt.figure(figsize = (20, 12))
plot = sns.barplot(monthly_stats.index, monthly_stats.values)
plt.xlabel("Month", fontsize = 20)
plot.set_xticklabels(labels)
plt.ylabel("Commits", fontsize = 20)
plt.title("Commits in each month of 2021", fontsize = 20)<jupyter_output>/home/mlouboutin3/GATechBundle/Miniconda3/lib/python3.8/site-packages/seaborn/_decorators.py:36: FutureWarning: Pass the following variables as keyword args: x, y. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation.
  warnings.warn(<jupyter_text>Everyday commits in October 2021<jupyter_code>commits['Date only'] = pd.to_datetime(commits['Date'].apply(lambda date: date.split('T')[0]))
commit_stats = commits[(commits['Year'] == '2021')
                       & (commits['Month'] == '10')]['Date only'].value_counts().sort_index()
labels = []
for value in commit_stats.index:
    labels.append(value.date())
    
plt.figure(figsize = (20, 12))
plot = sns.barplot(commit_stats.index, commit_stats.values)
plt.xlabel("Date", fontsize = 20)
plt.xticks(rotation = 90)
plot.set_xticklabels(labels)
plt.ylabel("Commits", fontsize = 20)
plt.title("Commits in October, 2021", fontsize = 20)<jupyter_output>/home/mlouboutin3/GATechBundle/Miniconda3/lib/python3.8/site-packages/seaborn/_decorators.py:36: FutureWarning: Pass the following variables as keyword args: x, y. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation.
  warnings.warn(<jupyter_text>Most popular languagesNext, I'll explore languages that we've used in each repository.<jupyter_code>list_of_languages = []
for languages in repos['Languages']:
    if type(languages) == str:
        for language in languages.split(','):
            list_of_languages.append(language.strip())
languages_count = pd.Series(list_of_languages).value_counts()

plt.figure(figsize = (20, 12))
sns.barplot(languages_count.index, languages_count.values)
plt.xlabel("Languages", fontsize = 20)
plt.xticks(rotation = 90)
plt.ylabel("Repositories", fontsize = 20)
plt.title("Language distribution amongst all repositories", fontsize = 20)<jupyter_output>/home/mlouboutin3/GATechBundle/Miniconda3/lib/python3.8/site-packages/seaborn/_decorators.py:36: FutureWarning: Pass the following variables as keyword args: x, y. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation.
  warnings.warn(
{'fraction_non_alphanumeric': 0.1338443396226415, 'fraction_numerical': 0.028744103773584904, 'mean_word_length': 5.895325203252033, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '623817', 'license': 'MIT', 'n_tokens_mistral': 2390, 'n_tokens_neox': 2155, 'n_words': 575, 'path': 'Github Insights.ipynb', 'repo_name': 'mloubout/GitHub-User-Insights-using-API', 'size': '6784'}