I have a pandas column with nested json data string. I'd like to flatten the data into multiple pandas columns. I have data like this:
{
'A': '123',
'B': '2019-08-26',
'C': [
{
'a': 'stop',
'b': 'A+'
},
{
'a': 'go',
'b': 'C+'
}
],
'D': [],
'E': [
{
'a': 'Don',
'b': 1
},
{
'b': 12
}
],
}
For each cell in pandas column, I'd like parse this string and create multiple columns. Expected output looks something like this:
| A | B | C.a | C.b | D.a | D.b | E.a | E.b |
|---- |------|-----|-----|-----|-----|-----|-----|
| 123 | 2019-08-26 | stop | A+ | Nan | Nan | Don | 1 |
| 123 | 2019-08-26 | go | C+ | Nan | Nan | Don | 1 |
| 123 | 2019-08-26 | stop | A+ | Nan | Nan | NaN | 12 |
| 123 | 2019-08-26 | go | C+ | Nan | Nan | Nan | 12 |
I tried using json_normalize, but it return error.... Please help me :(