我从一个yaml文件创建了这个json对象。我试图序列化它,但我得到了错误。在
{'info': {'city': 'Southampton',
'dates': [datetime.date(2005, 6, 13)],
'gender': 'male',
'match_type': 'T20',
'outcome': {'by': {'runs': 100}, 'winner': 'England'},
'overs': 20,
'player_of_match': ['KP Pietersen'],
'teams': ['England', 'Australia'],
'toss': {'decision': 'bat', 'winner': 'England'},
'umpires': ['NJ Llong', 'JW Lloyds'],
'venue': 'The Rose Bowl'},
'innings': [{'1st innings': {'deliveries': [{0.1: {'batsman': 'ME Trescothick',
'bowler': 'B Lee',
'non_striker': 'GO Jones',
'runs': {'batsman': 0, 'extras': 0, 'total': 0}}},
{'19.6': {'batsman': 'PD Collingwood',
'bowler': 'GD McGrath',
'non_striker': 'J Lewis',
'runs': {'batsman': 0, 'extras': 0, 'total': 0},
'wicket': {'fielders': ['RT Ponting'],
'kind': 'caught',
'player_out': 'PD Collingwood'}}}],
'team': 'England'}},
{'2nd innings': {'deliveries': [{'0.1': {'batsman': 'AC Gilchrist',
'bowler': 'D Gough',
'non_striker': 'ML Hayden',
'runs': {'batsman': 0, 'extras': 0, 'total': 0}}},
{'14.3': {'batsman': 'GD McGrath',
'bowler': 'SJ Harmison',
'non_striker': 'MS Kasprowicz',
'runs': {'batsman': 0, 'extras': 0, 'total': 0},
'wicket': {'kind': 'bowled', 'player_out': 'GD McGrath'}}}],
'team': 'Australia'}}]}
任何帮助都将不胜感激。我试图将这个json对象转换成csv文件中的一行。在
我试图运行的代码:
^{pr2}$错误
ValueError: Mixing dicts with non-Series may lead to ambiguous ordering.
IIUC您可以使用json_normalize()方法:
相关问题 更多 >
编程相关推荐