元のjsonデータに、
'weather':"[{'id': 502, 'main': 'Rain', 'description': 'heavy intensity rain', 'icon': '10d'}]"
というデータが入っているということでよろしいですか?
(要するにキー'weather'のデータがリテラルになっている)
ast.literal_eval
でリテラルを配列・辞書データへ変換できます。
normalizeする前にごっそり変換してしまえばよいでしょう。
あとはnormalize時に適切にrecord_path, record_prefixを付与すれば目的のデータ形式が出力できるかと。
python
1# テストデータ
2jsondata = [{'name': 'Alice', 'weather':"[{'id': 502, 'main': 'Rain', 'description': 'heavy intensity rain', 'icon': '10d'}]"},
3 {'name': 'Bob','weather':"[{'id': 101, 'main': 'Fine', 'description': 'Fine weather', 'icon': '1d'}]"}]
4
5# もし'weather'の中身がリテラルでなければこの処理は不要
6for d in jsondata:
7 d['weather'] = ast.literal_eval(d['weather'])
8
9print(pd.io.json.json_normalize(jsondata, record_path='weather', record_prefix='weather_'))
10'''
11出力結果:
12 weather_id weather_main weather_description weather_icon
130 502 Rain heavy intensity rain 10d
141 101 Fine Fine weather 1d
15'''
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。