Jan-28-2023, 09:19 PM
That depends on what is "meta"? Is meta a user that has an id == 178054?
import json import pandas as pd json_string = '[{"meta": {"user_id": "178054", "level_id": 1}}, {"beta": {"user_id": "178055", "level_id": 2}}]' game_data = json.loads(json_string) names = [key for player in game_data for key, value in player.items()] stats = [value for player in game_data for key, value in player.items()] game_df = pd.DataFrame(stats, index=names) print(game_df)
Output: user_id level_id
meta 178054 1
beta 178055 2
Or is meta something else? Should users be saved like this?import json import pandas json_string = '[{"meta": {"user_id": ["178054", "178055"], "level_id": [1, 2]}}]' game_data = json.loads(json_string)[0]["meta"] game_df = pandas.DataFrame(game_data) print(game_df)
Output: user_id level_id
0 178054 1
1 178055 2
Seeing a tiny snapshot of your json is not enough. You need to tell us what the json file mans.