Thanks in advance by all help.
I have a dataframe like this:
| client_id | product_id | product_name | timestamp_added | product_constraint |
|---|---|---|---|---|
| abc | fi2k | loug | 2021 | null |
| abc | fi2j | feb | 2021 | null |
| abc | fkn | ros | 2021 | skn |
| cbd | 01x | get | 2021 | lok |
| cbd | 018 | los | 2021 | hnc |
| cbd | 018 | vng | 2021 | hnc |
I need to do a dict by this df. Please note that client_id is not unique, event client_id as pk and product_id is not unique. Just the combination of client_id, product_id and product_constraint (that can be null in some cases) make a perfect unique identifier.
My dict needs to be like this:
{
"abc":[
{
"product_id":"fi2k",
"product_name": "loug",
"timestamp_added": 2021,
"product_constraint": null
},
{
"product_id":"fi2j",
"product_name": "feb",
"timestamp_added": 2021,
"product_constraint": null
},
{
...
}
],
"cbd":[
{
...
},
{
...
},
{
...
}
]
}
After this, i will use this dict to insert data into dynamodb.