DataFrame.to_dict(orient=’dict’)详解编程语言
编程语言 详解 to 8217 dict dataframe
2023-06-13 09:11:47 时间
df = pd.DataFrame({name:[1,2,3],"class":[11,22,33],"price":[111,222,333]}) class name price 0 11 1 111 1 22 2 222 2 33 3 333
orient : str {‘dict’, ‘list’, ‘series’, ‘split’, ‘records’, ‘index’}
Determines the type of the values of the dictionary.
dict (default) : dict like {column - {index - value}}
df.to_dict(orient="dict") {class: {0: 11, 1: 22, 2: 33}, name: {0: 1, 1: 2, 2: 3}, price: {0: 111, 1: 222, 2: 333}}
list : dict like {column - [values]}
df.to_dict(orient="list") {class: [11, 22, 33], name: [1, 2, 3], price: [111, 222, 333]}
series : dict like {column - Series(values)}
df.to_dict(orient="series") {class: 0 11 1 22 2 33 Name: class, dtype: int64, name: 0 1 Name: name, dtype: int64, price: 0 111 1 222 2 333 Name: price, dtype: int64}
split : dict like {index - [index], columns - [columns], data - [values]}
df.to_dict(orient="split") {index: [0, 1, 2], columns: [class, name, price], data: [[11, 1, 111], [22, 2, 222], [33, 3, 333]]}
records : list like [{column - value}, … , {column - value}]
df.to_dict(orient="records") [{class: 11, name: 1, price: 111}, {class: 22, name: 2, price: 222}, {class: 33, name: 3, price: 333}]
index : dict like {index - {column - value}}
df.to_dict(orient="index") {0: {class: 11, name: 1, price: 111}, 1: {class: 22, name: 2, price: 222}, 2: {class: 33, name: 3, price: 333}}
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/17083.html
cjava相关文章
- Spring Security 多登录实现详解编程语言
- JSP九大内置对象详解编程语言
- 解决FastJson com.alibaba.fastjson.JSONObject cannot be cast to的问题详解编程语言
- Java ConcurrentModificationException异常原因和解决方法详解编程语言
- SpringMVC通过邮件找回密码功能的实现详解编程语言
- python十进制转二进制,可指定位数详解编程语言
- css实现一款漂亮的查询框详解编程语言
- 使用JavaScript写的一个旋转的彩圈详解编程语言
- js获取当前系统时间详解编程语言
- python进阶Garbage collection垃圾回收2详解编程语言
- python全栈开发-Day3 字符串详解编程语言
- Akka(33): Http:Marshalling,to Json详解编程语言
- Scalaz(35)- Free :运算-Trampoline,say NO to StackOverflowError详解编程语言
- 泛函编程(14)-try to map them all详解编程语言
- Eclipse to android详解编程语言
- 字段内容过多,隐藏内容,鼠标移上…详解编程语言
- Hibernate之one-to-one双向外键关联Annotation详解编程语言
- 《Drools7.0.0.Final规则引擎教程》KIE概念&FACT对象详解编程语言
- ASM ClassReader failed to parse class file – probably due to a new Java class file version that isn’t supported yet详解编程语言
- 通过Excel生成批量SQL语句详解编程语言
- springMVC拦截器和过滤器总结详解编程语言
- Python3 pip命令报错:Fatal error in launcher: Unable to create process using ‘”‘详解编程语言
- Golang报错:Cannot convert expression of type interface{} to type []byte详解编程语言
- Unable to execute ‘doFinal’ with cipher instance详解编程语言
- Illegal unquoted character ((CTRL-CHAR, code X)): has to be escaped using backslash to be included in string value详解编程语言
- 常用增删改查动态(dynamic)实现详解编程语言
- PHP failed to ptrace(PEEKDATA) pid 13659: Input/output error错误解决方法详解编程语言
- SAP 自开发程序显示多条消息详解编程语言
- ECC TO HANA FAGLB03 search-help on Account Number field doesn’t working or not returning the selected value to the Account Number field.详解编程语言
- CMOD-采购订单抬头标准描述更改详解编程语言
- Make to Order (MTO) and Make to Stock (MTS)详解编程语言
- How to validate RFC connection in SAP详解编程语言
- SAP 发送邮件例子(内部)详解编程语言