How Can I convert this DF from pandas
Into this dictionary:
{"114811":{
"password-manager-active":[
{
"ref_date":"2021-10-04",
"value":"0",
"1_months":"0",
"2_months":"0",
"6_months":"0",
"12_months":"0",
"24_months":"3",
"60_months":"3"
},
{
"ref_date":"2021-10-04",
"value":"1",
"1_months":"0",
"2_months":"0",
"6_months":"0",
"12_months":"0",
"24_months":"0",
"60_months":"0"
}
],
"password-manager-installed":[
{
"ref_date":"2021-10-04",
"value":"0",
"1_months":"0",
"2_months":"0",
"6_months":"0",
"12_months":"0",
"24_months":"0",
"60_months":"0"
},
{
"ref_date":"2021-10-04",
"value":"1",
"1_months":"0",
"2_months":"0",
"6_months":"0",
"12_months":"0",
"24_months":"1",
"60_months":"1"
}
],
"password-manager-last-used":[
{
"ref_date":"2021-10-04",
"value":"1",
"1_months":"0",
"2_months":"0",
"6_months":"0",
"12_months":"0",
"24_months":"0",
"60_months":"0"
}
],
"password-manager-multifactor":[
{
"ref_date":"2021-10-04",
"value":"0",
"1_months":"0",
"2_months":"0",
"6_months":"0",
"12_months":"0",
"24_months":"0",
"60_months":"0"
},
{
"ref_date":"2021-10-04",
"value":"1",
"1_months":"0",
"2_months":"0",
"6_months":"0",
"12_months":"0",
"24_months":"0",
"60_months":"0"
}
],
"password-manager-reset-required":[
{
"ref_date":"2021-10-04",
"value":"0",
"1_months":"0",
"2_months":"0",
"6_months":"0",
"12_months":"0",
"24_months":"0",
"60_months":"0"
},
{
"ref_date":"2021-10-04",
"value":"1",
"1_months":"0",
"2_months":"0",
"6_months":"0",
"12_months":"0",
"24_months":"0",
"60_months":"0"
}
]
}}
I mean, I need to group by person_nid
and behavior_type
and then create a list of dicts for the records to be grouped where person_nid
is a key with another dictionary inside. In the nested dictionary, the keys are the behavior_type
and then the value for every behavior_type
is a list of dicts describing each record.