I have a dataframe that has a column called actions with a list of dictionaries. The format is {source:int, action:string} and i need to parse it into new columns for each, but the number of records in each action cell is variable.
the data looks like this:
|Id |action |
|1 |[{"E": 4, "action": "views"}, {"A": 58, "action": "views"}]|
|2 |[{"A": 74, "action": "clicks"}] |
and I would like it to look like this:
|Id|Source|Value|Action|
|1 |E |4 |views |
|1 |A |58 |views |
|2 |A |74 |clicks|
The number of dictionaries in the action column can be up to 10
I've tried a few solutions like this one pandas DataFrame: normalize one JSON column and merge with other columns
but it tells me that DataFrame was not called properly for the first solution and that str has no attribute value for the second one. Even beyond that it's not quite the solution i need because i need to rename a column source and put the A/E/etc value in it.