I have Dataframe as below.
name value id
A 123 1
B 345 5
C 567 4
D 789 2
I need to create a dictionary of the form below
{
{"name":"A",
"value":123,
"id":1
},
{"name":"B",
"value":345,
"id":5
},
{"name":"C",
"value":567,
"id":4
},
{"name":"D",
"value":789,
"id":2
}
}
I tried below code, but it makes 'name' as the key.
data_set.set_index('name').to_dict(orient='list')
How to get the dictionary of the form i have mention? Do i need to iterate through rows?