查看the pandas Documentation on DataFrame's to_json method , orient
参数的解释含糊不清。它接受的参数类型是字符串,而不是字典。然而,它似乎实际上可以接受三件事,每件事都有自己的默认值:系列(默认“索引”)、DataFrame(默认“列”)和“JSON 字符串的格式”(无默认值)。
我想知道 orient
参数的可接受值是什么,以及它们对输出 json 的作用。
最佳答案
JSON 字符串的格式就是每个参数的输出如下所示
- split : dict like {index -> [index], columns -> [columns], data -> [values]}
- 记录:像 [{column -> value}, ..., {column -> value}] 这样的列表
- index : dict like {index -> {column -> value}}
- columns : dict like {column -> {index -> value}}
- values : 只是值数组
关于python - pandas.DataFrame.to_json() 的 'orient' 参数的格式是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28953012/