1 回答

TA貢獻(xiàn)1828條經(jīng)驗(yàn) 獲得超13個贊
您可以將 JSON 讀入數(shù)據(jù)幀,然后將作者從列表轉(zhuǎn)換為字符串:
# 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
添加回答
舉報