python pandas convert nested dict in list to dataframe with differnt columns code example
Example: python How to convert a dictionary of dictionaries nested dictionary to a Pandas dataframe
dataframe = pd.DataFrame(nested_dictionary)
dataframe = dataframe.transpose()
import pandas as pd
student_data = {
0 : {
'name' : 'Aadi',
'age' : 16,
'city' : 'New york'
},
1 : {
'name' : 'Jack',
'age' : 34,
'city' : 'Sydney'
},
2 : {
'name' : 'Riti',
'age' : 30,
'city' : 'Delhi'
}
}
pandas_dataframe = pd.DataFrame(student_data)
print(pandas_dataframe)
0 1 2
age 16 34 30
city New york Sydney Delhi
name Aadi Jack Riti
pandas_dataframe.transpose()
age city name
0 16 New york Aadi
1 34 Sydney Jack
2 30 Delhi Riti