I have a dictionary that contains a key and a list of values. I want to make a simple pandas df, however, I am having trouble breaking out the list items into separate rows. My current approach creates a df but keeps the values in a list. How can I pull them out and add them as separate rows?
d = {'Car':['1','2','3'],
'Chicken legs':['4','5','6'],
'Coronary artery bypass graft surgery':['7','8','9','10','11','12']}
df = pd.DataFrame({'Thing':list(d.keys()), 'Values':list(d.values())})
Thing Values
0 Car [1, 2, 3]
1 Chicken_legs [4, 5, 6]
2 Coronary artery bypass graft surgery [7, 8, 9, 10, 11, 12]
Anticipated end result:
Thing Values
0 Car 1
1 Car 2
2 Car 3
3 Chicken_legs 4
4 Chicken_legs 5
5 Chicken_legs 6
6 Coronary artery bypass graft surgery 7
7 Coronary artery bypass graft surgery 8
8 Coronary artery bypass graft surgery 9
9 Coronary artery bypass graft surgery 10
10 Coronary artery bypass graft surgery 11
11 Coronary artery bypass graft surgery 12