import json
import pandas as pd
# read data
data = []
with open("/content/arxiv-metadata-oai-snapshot.json",'r') as f:
for idx, line in enumerate(f):
d = json.loads(line)
d = {'authors':d['authors'], 'categories':d['categories'], 'authors_parsed':d['authors_parsed']}
data.append(d)
data = pd.DataFrame(data)
print(data.head())
#print(data.describe())
# 数据统计
'''
统计所有作者姓名出现频率的Top10;
统计所有作者姓(姓名最后一个单词)的出现频率的Top10;
统计所有作者姓第一个字符的评率;
'''
# 选择类别为cs.CV下面的论文
data2 = data[data['categories'].apply(lambda x:'cs.CV' in x)]
# 拼接所有作者
all_authors = sum(data2['authors_parsed'],[])
all_authors
authors_names = [' '.join(x) for x in all_authors]
authors_names = pd.DataFrame(authors_names)
authors_names
import seaborn as sns
from bs4 import BeautifulSoup
import re
import requests
import matplotlib.pyplot as plt
# 根据作者出现频率绘制直方图
plt.figure(figsize = (10,6))
authors_names[0].value_counts().head(10).plot(kind = 'barh')
# 修改图的配置
names = authors_names[0].value_counts().index.values[:10]
_ = plt.yticks(range(0, len(names)), names)
plt.ylabel('Author')
plt.xlabel('Count')
# 统计姓,
authors_lastnames = [x[0] for x in all_authors]
authors_lastnames = pd.DataFrame(authors_lastnames)
plt.figure(figsize=(10, 6))
authors_lastnames[0].value_counts().head(10).plot(kind='barh')
names = authors_lastnames[0].value_counts().index.values[:10]
_ = plt.yticks(range(0, len(names)), names)
plt.ylabel('Author')
plt.xlabel('Count')
网友评论