我使用下面的代码创建了一个Pandas数据帧并输出到JSON:
dataDict['grant_id'] = list(grant_ids)
dataDict['patent_title'] = list(patent_title)
dfjson = dfjson.transpose()
dfjson = pd.DataFrame.from_dict(dataDict, orient='index')
output_json =dfjson.to_json('output_json.json')
{"0":
{"grant_id":"US10357643",
"patent_title":"System for enhanced sealing of coupled medical flui,
.... }}
但是,我不希望JSON中包含0。我希望它看起来像这样:
{"US10357643":{
"patent_title":"System for enhanced sealing of coupled medical flui,
.... }}
我想使用grant_id
作为索引,而不是0,1,2,3。。。有办法解决这个问题吗?你知道吗
我相信你需要^{} 和双转置:
因此,似乎需要在转置之前创建索引:
相关问题 更多 >
编程相关推荐