【发布时间】:2020-10-23 11:11:48
【问题描述】:
我正在尝试将数据框行转换为字典。
df
a b
0 paul active
1 marcus inactive
2 bruno active
3 scott inactive
4 anthony active
到行中的字典:
final_dict = {'paul':'active','marcus':'inactive','bruno':'active','scott':'inactive','anthony':'active'}
【问题讨论】:
-
这能回答你的问题吗? Convert a Pandas DataFrame to a dictionary
-
上述参考中的值要么在列表中,要么在字典中。
标签: python dataframe dictionary