尝试将嵌套的json读取为pandas数据框,但始终收到错误消息
ValueError: Mixing dicts with non-Series may lead to ambiguous ordering.
这是我尝试过的:
import json
file = json.load(open('../Datasets/MathNYC.json'))
file = pd.DataFrame(file)
我也尝试过使用json_normalize,而是获取单行数据,而不是多行数据
pd.DataFrame(pd.io.json.json_normalize(file))
以下是我的数据示例:
{'meta': {'view': {'id': 'x4ai-kstz',
'name': '2013-2017 School Math Results - Gender',
'averageRating': 0,
'category': 'Education',
'createdAt': 1506355113,
'displayType': 'table',
'downloadCount': 1106,
'hideFromCatalog': False,
'hideFromDataJson': False,
'indexUpdatedAt': 1536602847,
'locale': 'en_US',
'newBackend': True,
'numberOfComments': 0,
'oid': 26867540,
'provenance': 'official',
'publicationAppendEnabled': False,
'publicationDate': 1506356065,
'publicationGroup': 14486436,
'publicationStage': 'published',
'rowClass': '',
'rowsUpdatedAt': 1506355132,
'rowsUpdatedBy': 'fn2b-3u6b',
'tableId': 14486436,
'totalTimesRated': 0,
'viewCount': 370,
'viewLastModified': 1549924017,
'viewType': 'tabular',
'approvals': [{'reviewedAt': 1506356065,
'reviewedAutomatically': True,
'state': 'approved',
'submissionId': 1068765,
'submissionObject': 'public_audience_request',
'submissionOutcome': 'change_audience',
'submittedAt': 1506356065,
'workflowId': 2285,
'submissionDetails': {'permissionType': 'READ'},
'submissionOutcomeApplication': {'failureCount': 0, 'status': 'success'},
'submitter': {'id': 'fn2b-3u6b', 'displayName': 'Jose Beiro'}}],
'columns': [{'id': -1,
'name': 'sid',
'dataTypeName': 'meta_data',
'fieldName': ':sid',
'position': 0,
'renderTypeName': 'meta_data',
'format': {},
'flags': ['hidden']},
{'id': -1,
'name': 'id',
'dataTypeName': 'meta_data',
'fieldName': ':id',
'position': 0,
'renderTypeName': 'meta_data',
'format': {},
'flags': ['hidden']},
{'id': -1,
'name': 'position',
'dataTypeName': 'meta_data',
'fieldName': ':position',
'position': 0,
'renderTypeName': 'meta_data',
'format': {},
'flags': ['hidden']},
{'id': -1,
'name': 'created_at',
'dataTypeName': 'meta_data',
'fieldName': ':created_at',
'position': 0,
'renderTypeName': 'meta_data',
'format': {},
'flags': ['hidden']},
{'id': -1,
'name': 'created_meta',
'dataTypeName': 'meta_data',
'fieldName': ':created_meta',
'position': 0,
'renderTypeName': 'meta_data',
'format': {},
'flags': ['hidden']},
{'id': -1,
'name': 'updated_at',
'dataTypeName': 'meta_data',
'fieldName': ':updated_at',
'position': 0,
'renderTypeName': 'meta_data',
'format': {},
'flags': ['hidden']}]}}}