I have two dictionary dict1
and dict2
I am trying to load them using JSON
import json
y = json.loads(json.dumps([dict1, dict2]))
then trying to convert that to pdf
import pandas as pd
df = pd.DataFrame.from_dict(y, orient='index')
I am getting below error
AttributeError: 'str' object has no attribute 'values'
when I do it for one dictionary dict1
x = json.loads(dict1)
df_x = pd.DataFrame.from_dict(x, orient = 'index')
It is working. I understand that in second case as x
is loading as dictionary it is able to convert to dataframe. But, first case, as it is a list it is not working.
So, how can I convert list of dictionaries to dataframe?