如果您将整个json作为字典(或列表)加载(例如使用)
json.load,则可以使用
json_normalize:
In [11]: d = {"response": {"body": {"contact": {"email": "mr@abc.com", "mobile_number": "0123456789"}, "personal": {"last_name": "Muster", "gender": "m", "first_name": "Max", "dob": "1985-12-23", "family_status": "single", "title": "Dr."}, "customer": {"verified": "true", "customer_id": "1234567"}}, "token": "dsfgf", "version": "1.1"}}In [12]: df = pd.json_normalize(d)In [13]: df.columns = df.columns.map(lambda x: x.split(".")[-1])In [14]: dfOut[14]: email mobile_number customer_id verified dob family_status first_name gender last_name title token version0 mr@abc.com 0123456789 1234567 true 1985-12-23 single Max m Muster Dr. dsfgf 1.1
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)