Go-Frameworks-Github-Fork-Stats
In [1]:
Copied!
!pip install pandas matplotlib
!pip install pandas matplotlib
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip. Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue. To avoid this problem you can invoke Python with '-m pip' instead of running pip directly. Defaulting to user installation because normal site-packages is not writeable Requirement already satisfied: pandas in /home/deploy/.local/lib/python3.6/site-packages (1.0.0) Requirement already satisfied: matplotlib in /home/deploy/.local/lib/python3.6/site-packages (3.1.3) Requirement already satisfied: python-dateutil>=2.6.1 in /home/deploy/.local/lib/python3.6/site-packages (from pandas) (2.8.1) Requirement already satisfied: pytz>=2017.2 in /home/deploy/.local/lib/python3.6/site-packages (from pandas) (2019.3) Requirement already satisfied: numpy>=1.13.3 in /home/deploy/.local/lib/python3.6/site-packages (from pandas) (1.18.1) Requirement already satisfied: kiwisolver>=1.0.1 in /home/deploy/.local/lib/python3.6/site-packages (from matplotlib) (1.1.0) Requirement already satisfied: cycler>=0.10 in /home/deploy/.local/lib/python3.6/site-packages (from matplotlib) (0.10.0) Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /home/deploy/.local/lib/python3.6/site-packages (from matplotlib) (2.4.6) Requirement already satisfied: six>=1.5 in /home/deploy/.local/lib/python3.6/site-packages (from python-dateutil>=2.6.1->pandas) (1.14.0) Requirement already satisfied: setuptools in /home/deploy/.local/lib/python3.6/site-packages (from kiwisolver>=1.0.1->matplotlib) (45.1.0)
In [2]:
Copied!
import requests
import pandas as pd
import requests
import pandas as pd
In [3]:
Copied!
# 统计go框架fork次数信息
frameworks = {
"Gin":"gin-gonic/gin",
"Beego": "astaxie/beego",
"Iris": "kataras/iris",
"Revel": "revel/revel",
"Echo": "labstack/echo",
"Buffalo": "gobuffalo/buffalo"
}
stats = {}
for name in frameworks.keys():
url = "https://api.github.com/repos/" + frameworks[name]
stats[name] = requests.get(url=url).json() # 获取仓库统计信息
indexs = []
forks = []
stars = []
watchs = []
openIssues = []
for name in stats:
indexs += [name]
forks += [stats[name]['forks_count']] # fork次数
stars += [stats[name]['watchers_count']] # star次数
watchs += [stats[name]['subscribers_count']] # watch次数
openIssues += [stats[name]['open_issues_count']] # open_issue次数
df = pd.DataFrame({
'forks':forks,
'stars':stars,
'watchs':watchs,
'openIssues': openIssues
}, index = indexs)
df
# 统计go框架fork次数信息
frameworks = {
"Gin":"gin-gonic/gin",
"Beego": "astaxie/beego",
"Iris": "kataras/iris",
"Revel": "revel/revel",
"Echo": "labstack/echo",
"Buffalo": "gobuffalo/buffalo"
}
stats = {}
for name in frameworks.keys():
url = "https://api.github.com/repos/" + frameworks[name]
stats[name] = requests.get(url=url).json() # 获取仓库统计信息
indexs = []
forks = []
stars = []
watchs = []
openIssues = []
for name in stats:
indexs += [name]
forks += [stats[name]['forks_count']] # fork次数
stars += [stats[name]['watchers_count']] # star次数
watchs += [stats[name]['subscribers_count']] # watch次数
openIssues += [stats[name]['open_issues_count']] # open_issue次数
df = pd.DataFrame({
'forks':forks,
'stars':stars,
'watchs':watchs,
'openIssues': openIssues
}, index = indexs)
df
Out[3]:
forks | stars | watchs | openIssues | |
---|---|---|---|---|
Gin | 4074 | 35455 | 1212 | 242 |
Beego | 4688 | 23243 | 1268 | 813 |
Iris | 1942 | 17507 | 683 | 5 |
Revel | 1357 | 11575 | 558 | 87 |
Echo | 1508 | 16500 | 551 | 46 |
Buffalo | 430 | 5372 | 171 | 70 |
In [4]:
Copied!
df.plot(kind='bar', figsize=(15, 8))
df.plot(kind='bar', figsize=(15, 8))
Out[4]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f6786d59240>