Jan-28-2023, 08:13 PM
Hey all,
I am trying to convert a json file into a dataframe.
How can I achieve this?
I would be so grateful for a helping hand!
I am trying to convert a json file into a dataframe.
import pandas as pd import os from pandas.io.json import json_normalize data = [] path_to_json = '/Users/macbook/Desktop/Saveddata' json_files = [pos_json for pos_json in os.listdir(path_to_json) if pos_json.endswith('.json')] for i in range(0,len(json_files)): file = pd.read_json(r'/Users/macbook/Desktop/Saveddata/' + str(json_files[i])) file2 = file.iloc[113:] file2.iloc[0]output:
game-data [{'meta': {'user_id': '178054', 'level_id': 1,...In the example above, I would like 'user_id' to be a column header, 'level_id' to be a column header etc. '170854' would be the first row of the first column and '1' would be the first row of the second column.
How can I achieve this?
I would be so grateful for a helping hand!