我有一个包含嵌套JSON数据的列表,我想将'data:'标记中的所有内容转换为 Dataframe 。列表中包含多条记录
emptylist = [{'data': {'id': 7478290440, 'version': 0, 'bonus_opening_balance': 7.4, 'cash_opening_balance': 30.83, 'external_round_id': '8997958938', 'game_id': 29788, 'game_session_id': 144418070, 'last_updated_at': '2023-06-29T14:03:03Z', 'started_at': '2023-06-29T14:03:03Z', 'status': 0, 'cash_stake': 0, 'cash_win': 0, 'bonus_stake': 0, 'bonus_win': 0}, 'metadata': {'timestamp': '2023-06-29T12:03:07.699650Z', 'record-type': 'data', 'operation': 'insert', 'partition-key-type': 'schema-table', 'schema-name': 'revolve', 'table-name': 'game_round', 'transaction-id': 103414267563647}}, {'data': {'id': 7478290359, 'version': 2, 'bonus_opening_balance': 0, 'cash_opening_balance': 11.13, 'ended_at': '2023-06-29T14:03:03Z', 'external_round_id': '8997958480', 'game_id': 16210, 'game_session_id': 144418025, 'last_updated_at': '2023-06-29T14:03:03Z', 'started_at': '2023-06-29T14:02:58Z', 'status': 1, 'cash_stake': 0.2, 'cash_win': 0.03, 'bonus_stake': 0, 'bonus_win': 0}, 'metadata': {'timestamp': '2023-06-29T12:03:07.708711Z', 'record-type': 'data', 'operation': 'update', 'partition-key-type': 'schema-table', 'schema-name': 'revolve', 'table-name': 'game_round', 'transaction-id': 103414267564722}}, {'data': {'id': 7478290440, 'version': 1, 'bonus_opening_balance': 7.4, 'cash_opening_balance': 30.83, 'external_round_id': '8997958938', 'game_id': 29788, 'game_session_id': 144418070, 'last_updated_at': '2023-06-29T14:03:03Z', 'started_at': '2023-06-29T14:03:03Z', 'status': 0, 'cash_stake': 0.2, 'cash_win': 0, 'bonus_stake': 0, 'bonus_win': 0}, 'metadata': {'timestamp': '2023-06-29T12:03:07.717096Z', 'record-type': 'data', 'operation': 'update', 'partition-key-type': 'schema-table', 'schema-name': 'revolve', 'table-name': 'game_round', 'transaction-id': 103414267565254}}]
print(emptylist)
2条答案
按热度按时间pxy2qtax1#
您可以从列表中创建DataFrame,并在
"data"
系列上使用apply
使其成为DataFrame:gmol16392#
试试这个