我有一个国家的清单,应该变成一个数据框架。问题是每个国家和数据在列表中都是一个单独的词。例如:
[
'Viet',
'Nam',
'0',
'12.3',
'0',
'Brunei',
'Darussalam',
'12',
'1.1',
'0',
'Bosnia',
'and',
'Herzegovina',
'2',
'2.1',
'0',
'Not',
'applicable',
'Turkey',
'4',
'4.3',
'0',
'Only',
'partial',
'coverage'
...
]
如何将其转换为: [ [‘越南’、‘0’、‘12.3’、‘0’], [‘文莱达鲁萨兰国’、‘12’、‘1.1’、…], ... ] 或“pd.DataFrame”:
country coef1 coef2 grade
0 Viet Nam 0 12.3 0
1 Brunei Darussalam 12 1.1 0
注意:有些国家有一个单词,如中国、法国或三个或更多单词,如大韩民国。此外,有时在这一系列数字之后会有一个备注
试试这个:
其中,中的数据是您要分析的数据,国家是世界上所有国家的列表
.DataFrame输出:
相关问题 更多 >
编程相关推荐