dfList = df.values.tolist()
return jsonify(dfList)
结果是,它实际上删除了数据帧的变量名,并用整数替换它们
^{pr2}$我的结果应该是这样的,包括数据帧中的变量
-0: [
"texte": "Les abeilles sont dehors",
"type": "ObservationNature",
"nluScore": 0.6790075732725341,
"ruche": [],
],
-1:[
"texte": "elle sont allée chercher le miel à coté des fleurs du rucher",
"type": "ObservationNature",
"nluScore": 0.4250480624587389,
"ruche": [],
],
这是因为要将ndarray类型传递给jsonify。在
尽管df.to_json文件(orient=“records”)将为您服务, 您可以通过数据框错误()和/或defaultdit 下面是一个例子:
如果你跑了
它应该为您提供所需的输出(注:从Pandas版本0.23.3开始)
查找pandas documentation
使用“index”格式的JSON对数据帧进行编码/解码:
^{pr2}$使用“columns”格式的JSON对数据帧进行编码/解码:
使用“values”格式的JSON对数据帧进行编码/解码:
相关问题 更多 >
编程相关推荐