example dictionary:
sample_dict = {'doctor': {'docter_a': 26, 'docter_b': 40, 'docter_c': 42},
'teacher': {'teacher_x': 21, 'teacher_y': 45, 'teacher_z': 33}}
output dataframe:
job person age
doctor |doctor_a | 26
doctor |doctor_b | 40
doctor |doctor_c | 42
teacher|teacher_x| 21
teacher|teacher_y| 45
teacher|teacher_z| 33
I have tried:
df = pd.dataFrame.from_dict(sample_dict)
=>
doctor teacher
doctor_a | 26 | Nah
doctor_b | 40 | Nah
doctor_c | 42 | Nah
teacher_x | Nah | 21
teacher_y | Nah | 45
teacher_z | Nah | 33
Could someone help me figure this out?