[Python] JSON to dataframe
2022. 4. 4. 08:11ㆍ파이썬
json_normalize
import pandas as pd
import json
from pandas import json_normalize
data = '''
{
"Results":
[
{ "id": "1", "Name": "Jay" },
{ "id": "2", "Name": "Mark" },
{ "id": "3", "Name": "Jack" }
],
"status": ["ok"]
}
'''
info = json.loads(data)
df = json_normalize(info['Results']) #Results contain the required data
print(df)
출력:
id Name
0 1 Jay
1 2 Mark
2 3 Jack
출처 : https://www.delftstack.com/ko/howto/python-pandas/json-to-pandas-dataframe/
'파이썬' 카테고리의 다른 글
[Python] GroupBy 분할, 적용, 결합 (aggregate, apply, filter, transform) (0) | 2022.04.05 |
---|---|
[Python] json to dataframe (0) | 2022.04.04 |
[Python] Colab(코랩)과 로컬 Pycharm 연동하기 (6) | 2021.12.08 |
[python] shift() , pct_change(), diff(), rolling(), resample() (0) | 2021.10.13 |
[python] tf.constant vs tf.Variable (0) | 2021.09.23 |