在我的dataframe中,有些列采用OrderedDictionary格式。如何将它们转换为新列(不知道哪些列包含OrderedDictionary和OrderedDictionary中的元素)
示例列:
inventors
[OrderedDict([('@sequence', '001'), ('@app-type', 'applicant'), ('@designation', 'us-only'), ('addressbook', OrderedDict([('last-name', 'Nahm'), ('first-name', 'Seung Hoon'), ('address', OrderedDict([('city', 'Daejeon'), ('country', 'KR')]))])), ('residence', OrderedDict([('country', 'KR')]))]), OrderedDict([('@sequence', '002'), ('@app-type', 'applicant'), ('@designation', 'us-only'), ('addressbook', OrderedDict([('last-name', 'Jang'), ('first-name', 'Hoon Sik'), ('address', OrderedDict([('city', 'Daegu'), ('country', 'KR')]))])), ('residence', OrderedDict([('country', 'KR')]))])]
我想将其转换为以下数据帧(未写入所有列):
@sequence1 @app_type1 @designation1 @last_name1 @first_name1 ....
001 applicant us_only Nahm Seung Hoon
在本例中,姓和名来自另一个嵌套字典。在数据中,我不知道哪些列包含OrderedDictional,为了简单起见,我只包含了数据集中的一列,即inventors
你考虑过熊猫from_dict()函数吗?你知道吗
相关问题 更多 >
编程相关推荐