So I have a piece of JSON code and I want to turn it into a DataFrame, however I am quite new to DataFrames so I am a bit stuck. Any help would be appreciated :)
So this is my code:
data = response.json()
data_pretty = json.dumps(data, sort_keys=True, indent=4)
data_frame = pd.DataFrame(data)
# Pretty print
print(data_pretty)
print(data_frame)
This is the output:
{
"status": "OK",
"users": [
{
"email": "[email protected]",
"first_name": "Raf",
"id": "24959",
"last_name": "Rasenberg"
},
{
"email": "[email protected]",
"first_name": "Raf",
"id": "25795",
"last_name": "Rasenberg"
}
]
}
status users
0 OK {'id': '24959', 'email': '[email protected]', ...
1 OK {'id': '25795', 'email': 'raf.rasenberg@gmail....
As you can see it needs some additional tweaking, I only want to show the columns 'email', 'first_name', 'id' and 'last_name'. Can someone help me out?
pd.DataFrame(data.get('users'))?