我正在尝试从mongoDB集合转储创建数据帧。你知道吗
我引用了这个question来规范我的数据,但是它不t help. The output doesn
包含文件名和id
我想在我的数据框中有文件名和id。你知道吗
这是我的json示例
[
{'FileName': '32252652D.article.0018038745057751440210.tmp',
'_id': {'$oid': '5ced0669acd01707cbf2ew33'},
'section_details': [{'content': 'Efficient Algorithms for Non-convex Isotonic '
'Regression through Submodular Optimization ',
'heading': 'title'},
{'content': 'We consider the minimization of submodular '
'functions subject to ordering constraints. We show that '
'this potentially non-convex optimization problem can '
'be cast as a convex optimization problem on a space of '
'uni-dimensional measures',
'heading': 'abstract'},
{'content': '', 'heading': 'subject'},
{'content': ' Introduction to convex optimization'
'with mean ',
'heading': 'Content'}]},
{'FileName': '32252652D.article.0018038745057751440210.tmp',
'_id': {'$oid': '5ced0669acd01707cbf2ew11'},
'section_details': [{'content': 'Text-Adaptive Generative Adversarial Networks: '
'Manipulating Images with Natural Language ',
'heading': 'title'},
{'content': 'This paper addresses the problem of manipulating '
'images using natural language description. Our '
'task aims to semantically modify visual '
'attributes of an object in an image according '
'to the text describing the new visual',
'heading': 'abstract'},
{'content': '', 'heading': 'subject'},
{'content': ' Introduction to Text-Adaptive Generative Adversarial Networks',
'heading': 'Content'}]}
]
预期产量
请让我知道,如果你愿意输出为:
json_normalize
方法可以被传递一个元数据数组以添加到每个记录中。你知道吗在这里,假设js包含来自原始json的数据,您可以使用:
您将获得:
之后,您仍然需要修复
_id
列并透视数据帧。最后,你可以以:或者,您可以直接从原始json的每一行手工构建一个dataframe行:
相关问题 更多 >
编程相关推荐