第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

將 JSON 數(shù)據(jù)轉(zhuǎn)換為 Pandas DataFrame

將 JSON 數(shù)據(jù)轉(zhuǎn)換為 Pandas DataFrame

牛魔王的故事 2023-07-11 15:26:13
"{\".travis.yml\": {\"auth_count\": 1, \"authors\": {\"py/set\": [\"Alexandr Tsaplin\"]}, \"count\": 1}, \"fleetspeak/client-mac/com.google.code.fleetspeak.plist\": {\"auth_count\": 1, \"authors\": {\"py/set\": [\"mol123\"]}, \"count\": 1}, \"fleetspeak/src/client/client/client.go\": {\"auth_count\": 1, \"authors\": {\"py/set\": [\"mol123\"]}, \"count\": 1}, \"fleetspeak/src/client/client_test.go\": {\"auth_count\": 2, \"authors\": {\"py/set\": [\"Ben Galehouse\", \"mol123\"]}, \"count\": 2}, \"fleetspeak/src/client/entry/entry_unix.go\": {\"auth_count\": 1, \"authors\": {\"py/set\": [\"mol123\"]}, \"count\": 1}, \"fleetspeak/src/client/entry/entry_windows.go\":我想將 JSON 數(shù)據(jù)(存儲在 result.json 文件中)轉(zhuǎn)換為數(shù)據(jù)幀。我希望我的數(shù)據(jù)框看起來像所附圖像中的數(shù)據(jù)框。
查看完整描述

1 回答

?
慕田峪7331174

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


查看完整回答
反對 回復(fù) 2023-07-11
  • 1 回答
  • 0 關(guān)注
  • 119 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號