【发布时间】:2017-06-26 20:55:32
【问题描述】:
我正在尝试从以下多索引数据帧创建嵌套字典列表,其中索引构成第一级 {key:value},索引下的行构成嵌套字典。
[{'date':1980, 'country': 'United States', 'country_id':840
'count':42, 'players' : [{'player_name: xxxx','ranking': 46, 'hand': 'r'}, {'player_name: yyy', 'ranking':20, 'hand': 'r'}...]},
{'date':1980, 'country': 'Czech Republic', 'country_id':203,
'count':42, 'players' : [{'player_name: xxxx','ranking': 46, 'hand':'r'},
{'player_name: yyy', 'ranking':20, 'hand': 'r'}...]},...
{'date':1982, 'country': 'United States', 'country_id':840,
'count':42, 'players' : [{'player_name: xxxx','ranking': 46, 'hand': 'r'},...]
HAND RANKING PLAYER_NAME
DATE COUNTRY COUNTRY_ID COUNT
1980 United States 840 42 R 46 Tim Gullikson
42 L 96 Nick Saviano
42 L 3 Jimmy Connors
42 L 79 Bruce Manson
Czech Republic 203 2 R 23 Tomas Smid
2 R 65 Pavel Slozil
New Zealand 554 3 R 66 Chris Lewis NZL
.
.
1982 United States 840 42 L 46 Van Winitsky
42 R 24 Steve Denton
42 R 26 Mel Purcell
3 R 76 Russell Simpson
.
.
【问题讨论】:
标签: pandas dictionary dataframe nested