I am running Python 3.8 and Pandas 0.19.2 and have a DataFrame which looks as follows:
| id_number | name | amount | addenda |
|---|---|---|---|
| 1234 | ABCD | $100 | Car-wash-$30 |
| 1234 | ABCD | $100 | Maintenance-$70 |
I need a dictionary/JSON like below:
[
{
'id_number': 1234,
'name': 'ABCD',
'amount': '$100',
'addenda': [
{'payment_related_info': 'Car-wash-$30'},
{'payment_related_info': 'Maintenance-$70'}
]
}
]
I tried using groupby and to_dict, but it did not work. Any suggestions? Thanks up front for the help.