当前位置:网站首页>Represent each record in the dataframe as a dictionary
Represent each record in the dataframe as a dictionary
2022-06-21 08:11:00 【Still forge ahead】
import pandas as pd
data ={
'name':['Tom','Jarry','Marry','Ali'],
'age':[18,20,21,21],
'major':['Math','English','Physics','Math']
}
df1 = pd.DataFrame(data)
print(df1)
#output
name age major
0 Tom 18 Math
1 Jarry 20 English
2 Marry 21 Physics
3 Ali 21 Math
data_dict = df1.to_dict(orient='records')
print(data_dict)
#output
[{'name': 'Tom', 'age': 18, 'major': 'Math'}, {'name': 'Jarry', 'age': 20, 'major': 'English'}, {'name': 'Marry', 'age': 21, 'major': 'Physics'}, {'name': 'Ali', 'age': 21, 'major': 'Math'}]
边栏推荐
- Actual use case of strategic routing in a school cloud computer project
- 群晖DSM7添加套件源
- 面试鸭 面试刷题 网站系统源码
- 2021-07-28 STM32F103 I2C Hardware Transfer Include previous IO Clock EXIT USB use firmware library
- showCTF Web入门题系列
- 2021-06-16 STM32F103 EXTI 中斷識別 使用固件庫
- Why is there no error in the code, but the data in the database cannot be displayed
- Global and Chinese market of filter microplate reader 2022-2028: Research Report on technology, participants, trends, market size and share
- Firefox users are down, Mozilla foundation is at a crossroads
- [kotlin] first day
猜你喜欢

How can we make millions a year now?

Eureka's timedsupersortask class (periodic task with automatic interval adjustment)

MMS for risc-v

5分钟搞懂MySQL - 行转列
![[untitled]](/img/25/4725977134d41b5d6f5d86b60ec731.jpg)
[untitled]

测试入门——软件测试模型

线上GO服务出现GC故障,我当时就急了

Vision_ Transformer code exercise

图解 Google V8 # 14:字节码(二):解释器是如何解释执行字节码的?

Haidilao is expected to have an annual net loss of 3.8 billion to 4.5 billion and close more than 300 stores
随机推荐
2022-2028 global cooling on-off valve industry research and trend analysis report
Cluster hui dsm7 add suite source
[kotlin] premier jour
运算符优先级与结合顺序
[kotlin] first day
写文章的markdown规则
You can't use typescript generics after reading it. Come to me for yyds dry inventory
2021-07-28 STM32F103 I2C Hardware Transfer Include previous IO Clock EXIT USB use firmware library
怎么搭建深度学习框架?
Bean实例化的三种方法
為什呢代碼沒報錯但是數據庫裏邊的數據顯示不出來
Global and Chinese market for diamond blades 2022-2028: Research Report on technology, participants, trends, market size and share
Operator priority and combining order
How can we make millions a year now?
Showctf web primer series
Is the index of nine interview sites of ten companies invalid?
Illustration Google V8 14: bytecode (2): how does the interpreter interpret and execute bytecode?
[redis]-[redis underlying data structure] - Dictionary
图解 Google V8 # 14:字节码(二):解释器是如何解释执行字节码的?
Flutter returns to the black screen of the previous page