I have a json file which I converted to dict like below:
{'DATA': [{'COMPANY_SCHEMA': 'ABC', 'CONFIG_TYPE': 'rtype', 'IM_ID': '44f8d1b4_437e', 'MODIFIED_DATE': 'Unknown', 'ID': 'Test', 'CONFIG_KEY': 'posting_f', 'SYSTEM_NUMBER': '50', 'SYS_CONFIG_VALUE': '0', 'SYS_CONFIG_STRING_VALUE': 'true'}
I wrote the following code to convert a json file to above dict format
with open('data.json') as data_file:
data = json.load(data_file)
Now I am trying to store this dict as pandas data frame with keys as column headers.
So I write below:
df=pd.DataFrame.from_dict(data,orient='columns')
But I get all columns as one column.
df.head(3)
DATA
0 {'COMPANY_SCHEMA': 'ABC.', 'CON...
1 {'COMPANY_SCHEMA': 'ABC', 'CON...
2 {'COMPANY_SCHEMA': 'ABC', 'CON...
I basically have a bunch of such json files in a folder and I am trying to read all of them and store in one pandas data frame appended one below the other.
So I was trying above. So
1) why the above error when converting to pandas data frame and
ii) Is there a better and faster way to read a bunch of such files and append to one json and then add it to pandas frame or one by one?