【发布时间】:2020-07-22 22:41:27
【问题描述】:
具有以下形式的数据框:
element1 | element2 | element3
cat bird plane
dog poodle cloud
pig bike sky
我想将其转换为表单列表的字典
{ 'element1' : ['cat', 'dog', 'pig'],
'element2' : ['bird', 'poodle', 'bike'],
'element3' : ['plane', 'cloud', 'sky'] }
我正在查看.to_dict 方法的documentation,但似乎没有一个选项能满足我的需要。
【问题讨论】:
标签: python pandas dataframe dictionary