I have a json file that I am trying to unpack that looks like this:
[{'batter': 'LA Marsh',
'bowler': 'MJG Nielsen',
'non_striker': 'M Kapp',
'runs': {'batter': 0, 'extras': 0, 'total': 0}},
{'batter': 'LA Marsh',
'bowler': 'MJG Nielsen',
'non_striker': 'M Kapp',
'runs': {'batter': 0, 'extras': 0, 'total': 0},
'wickets': [{'player_out': 'LA Marsh', 'kind': 'bowled'}]},
{'batter': 'EA Perry',
'bowler': 'MJG Nielsen',
'non_striker': 'M Kapp',
'runs': {'batter': 0, 'extras': 0, 'total': 0}}]
using the following code:
df = pd.json_normalize(data)
I get the following:
As you can see, the second entry has a nested list in it. In place of the column 'wickets' I would like to have two columns "player_out" and "kind". My preferred output looks like this: