【发布时间】:2017-10-03 23:11:01
【问题描述】:
我正在尝试将 pandas 数据框转换为字典,我目前正在获得以下输出:
{'country': {0: 'BRAZIL', 1: 'BRAZIL'}, 'store_nick': {0: 'store_a', 1: 'store_b'}, 'store': {0: 'STORE_A', 1: 'STORE_B'}}
但我想要这种格式:
{{'store_a','BRAZIL', 'STORE_A'}, {'store_b','BRAZIL', 'STORE_B'}}
这是我的代码:
dimensions[['fieldA','fieldB','fieldC']].to_dict()
我该如何解决这个问题?
【问题讨论】:
-
{{'store_a','BRAZIL', 'STORE_A'}, {'store_b','BRAZIL', 'STORE_B'}}不是字典。
标签: python pandas dictionary dataframe