我有一個看起來像一個數據幀:熊貓:轉換數據框欄與欄標題爲字典鍵和col值字典作爲字典值
NAME ID
155 ARBITRARY_A 697381
208 ARBITRARY_B 691820
265 ARBITRARY_C 691782
272 ARBITRARY_D 695593
我想把它轉換成一個字典列表,看起來如:
[{name:ARBITRARY_A, id:697381}, {name:ARBITRARY_B, id:691820},
{name:ARBITRARY_C, id:691782}, {name:ARBITRARY_D, id:695593}]
什麼是最快/最佳的方式來做這個操作?
'df.to_dict('record')'? – johnchase