所以问题在于它是一个csv文件,当我用熊猫打开它时,它看起来像这样:
data=pd.read_csv('test.csv', sep=',', usecols=['properties'])
data.head()[![enter image description here][1]][1]
就像每一行的字典一样,只是混淆了如何正确地用性别,document_type等作为列来打开它
{'gender':'男性','国籍':'IRL','document_type':'护照','date_of_expiry':'2019-08-12','issuing_country':'IRL'} >
{'gender':'Female','document_type':'driving_licence','date_of_expiry':'2023-02-28','issuing_country':'GBR'}
{'gender':'男性','国籍':'ITA','document_type':'护照','date_of_expiry':'2018-06-09','issuing_country':'ITA'} >
答案 0 :(得分:0)
cvs文件的格式似乎不正确,无法通过默认功能从熊猫读取。您将需要自己创建列。
0
对于词典中的每个字段。
如果列太多,则应考虑评估字符串。像这样
data['gender'] = data['properties'].str[0].str['gender']
这应该可以很好地构建您的DataFrame