当前位置:网站首页>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'}]
边栏推荐
- Le Code est correct, mais les données de la base de données ne sont pas affichées.
- PHP类与对象详细介绍
- Complex four operations (23 lines of concise code)
- 2021-07-28 STM32F103配置信息
- 群暉DSM7添加套件源
- Bean实例化的三种方法
- Firefox users are down, Mozilla foundation is at a crossroads
- 2021-07-28 STM32F103 I2C Hardware Transfer Include previous IO Clock EXIT USB use firmware library
- Global and Chinese market for diamond blades 2022-2028: Research Report on technology, participants, trends, market size and share
- Summary of command execution knowledge points in CTF
猜你喜欢

日记(C语言总结)

Haidilao is expected to have an annual net loss of 3.8 billion to 4.5 billion and close more than 300 stores

使用Lua+Redis+OpenResty实现电商首页并发优化

MMS for risc-v

2021-06-16 STM32F103 EXTI 中断识别 使用固件库

Vision_ Transformer code exercise
![[putty] a free SSH and telnet client](/img/3b/2513ba6ca9fe7e4ed43afcf978e3f6.jpg)
[putty] a free SSH and telnet client

Flutter returns to the black screen of the previous page

RISC-V 的MMU

A table to easily understand the prefix and suffix of increment and decrement operators
随机推荐
Global and Chinese market for military imaging systems 2022-2028: Research Report on technology, participants, trends, market size and share
What aspects should the enterprise multimedia exhibition hall design start from
微信公众号对接 : 一键推送文章信息至公众号
[Redis]-[Redis底层数据结构]-字典
(thinking) C. differential sorting
Blank screen of virtual machine browser
A table to easily understand the prefix and suffix of increment and decrement operators
Illustration Google V8 14: bytecode (2): how does the interpreter interpret and execute bytecode?
5分钟搞懂MySQL - 行转列
antd table长表格如何出现滚动条
Showctf starter file contains series
文件下载 二进制流的形式构造url和base64下载
Illustration of Google V8 16: how does V8 improve function execution efficiency through inline caching?
[yuanuniverse 3D competition]
Leetcode topic [array] -40- combined sum II
An improvement of the code in the article "Walkthrough: creating paged data access using web form pages" in MSDN
/home/ljx/miniconda3/compiler_ compat/ld: cannot find crtbeginS. o: There is no such file or directory
2021-06-16 STM32F103 EXTI 中斷識別 使用固件庫
Multiplication and addition of univariate polynomial (20 points)
Solve the problem that Jenkins cannot save the configuration after upgrading