我使用以下命令将pandas数据帧输出到json对象:
df_as_json = df.to_json(orient='split')
json对象中存储了多余的索引。我不想包括这些。在
我试着移除它们
^{pr2}$
但是我得到了
AttributeError: 'str' object has no attribute 'to_json'
是否有一种快速的方法来重新组织dataframe,使其在.to\u json(orient='split')调用期间或之前不包含单独的索引列?在
Tags:
to_json(orient='split')
转换为json
json
模块将该字符串加载到字典中del json_dict['index']
删除{json.dump
或json.dumps
将字典转换回json
演示
Since two years back
pandas
(>= v0.23.0)提供一个index
参数(仅对orient='split'
和orient='table'
有效):https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.to_json.html
相关问题 更多 >
编程相关推荐