I have a pandas dataframe with two columns- group_id and personal_score. The group id column contains some id numbers, where the personal score column contains dictionaries of different length. Here is an example:
group_id personal_score
0 77 {'149': 17, '819': 22}
1 37 {'821': 18, '359': 24, '089': 17, '170': 15}
2 51 {'280': 18, '261': 18, '628': 20, '722': 21, '744': 19, '152': 19}
3 84 {'140': 19}
I want to split the dictionaries in the personal_score column into two columns, personal_id that takes the key of the dictionary and score that takes the value while the value in the group_id column is repeated for all splitted rows from the correspondent dictionary. The output should look like:
group_id personal_id score
0 77 149 17
1 77 819 22
2 37 821 18
3 37 359 24
4 37 089 17
5 37 170 15
6 51 280 18
7 51 261 18
8 51 628 20
9 51 722 21
10 51 744 19
11 51 152 19
12 84 140 19
Your help is much appreciated.