回答編集履歴

1

Update

2022/05/20 15:35

投稿

melian
melian

スコア19825

test CHANGED
@@ -5,13 +5,11 @@
5
5
 
6
6
  pd.set_option('display.unicode.east_asian_width', True)
7
7
 
8
- with open('test.json') as f:
8
+ with open('test.json') as f: js = json.load(f)
9
+ df = pd.json_normalize(js, 'records')[['createdAt', 'post.title', 'messageId']]\
9
- js = json.load(f)
10
+ .rename(columns=lambda x: x.split('.')[-1])
10
11
 
11
- df = pd.json_normalize(js, 'records')[['createdAt', 'post.title', 'messageId']]
12
- df.columns = ['createdAt', 'title', 'messageId']
13
12
  #df.to_excel('test.xlsx', sheet_name='sheet', index=False, header=True)
14
-
15
13
  print(df)
16
14
 
17
15
  #