https://www.delftstack.com/ko/howto/python-pandas/json-to-pandas-dataframe/
json_normalize()
를 사용하여 Pandas DataFrame에 JSON
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
read_json()
을 사용하여 Pandas DataFrame에 JSON
import pandas as pd
data = '''
{
"0":{
"Name": "Jay",
"Age": "17"
},
"1":{
"Name": "Mark",
"Age": "15"
},
"2":{
"Name": "Jack",
"Age":"16"
}
}
'''
df = pd.read_json(data, orient ='index')
print(df)
# 출력
Name Age
0 Jay 17
1 Mark 15
2 Jack 16