1 回答
TA贡献1828条经验 获得超13个赞
您可以将 JSON 读入数据帧,然后将作者从列表转换为字符串:
# read json from string `s` to a dataframe
df = (pd.read_json(s).T
.reset_index()
.rename(columns={'index': 'Filename', 'auth_count': 'authors_count'}))
# convert lists of authors to comma-separated strings
df['authors'] = df['authors'].apply(lambda x: ', '.join(x['py/set']))
df
输出:
Filename authors_count authors count
0 .travis.yml 1 Alexandr Tsaplin 1
1 fleetspeak/clien... 1 mol123 1
2 fleetspeak/src/c... 1 mol123 1
3 fleetspeak/src/c... 2 Ben Galehouse, m... 2
4 fleetspeak/src/c... 1 mol123 1
5 fleetspeak/src/c... 1 mol123 1
6 fleetspeak/src/c... 1 mol123 1
添加回答
举报