I have a dataframe of strings. The current dataframe looks like this: Current dataframe
Each datapoint contains a Dictionary like below:
"{'Index': 1, 'TimeSpent': 74088, 'RealInc': 'Obstacle_bef', 'IdentifiedIncident': 'Obstacle', 'TrLev': 7, 'TakeOverDecision': 'stay_put'},{'Index': 2, 'TimeSpent': 11336, 'RealInc': 'Obstacle_after_success', 'IdentifiedIncident': 'Pedestrian', 'TrLev': 7 },{'Index': 3, 'TimeSpent': 38594, 'RealInc': 'Cyclist_before', 'IdentifiedIncident': 'Cyclist', 'TrLev': 7, 'TakeOverDecision': 'stay_put'},{'Index': 4, 'TimeSpent': 16011, 'RealInc': 'Cyclist_after_success', 'IdentifiedIncident': 'Pedestrian', 'TrLev': 7 }".
I would like to make a new dataframe where each colomn represents the key of that dictionary. I have tried to use eval()
, as well as using apply
like this. But I think because every other dict is missing the key of 'TakeOverDecision'
, the apply does not work on it.
Any suggestions or guidance on how to split this to a dataset which make my dataset looks like below would be great! Desired dataframe