【python教程】数据分析——numpy、pandas、matplotlib_哔哩哔哩 (゜-゜)つロ 干杯~-bilibiliwww.bilibili.com
![4a197d8a17af58b62f3ca8364e399e51.png](https://i-blog.csdnimg.cn/blog_migrate/fad1a882993e08fa90409be14a9b1b02.jpeg)
目录
- pandas模块
- pandas常用数据类型
- pandas之Series切片和索引
- pandas读取外部数据
- pandas之DataFrame
四、pandas模块
pandas在numpy的基础上,除了能帮助我们处理数值型的数组,还能处理字符串、时间序列、列表、字典等数据类型的数据。
pandas常用数据类型
Series:一维、带标签数组,Series对象本质上是由两个数组构成,一个数组构成对象的键(index),一个数组构成对象的值(values)
DataFrame:二维数组,是Series容器
import pandas as pd
import string
# 创建数组
t1 = pd.Series([1,2,21,31,41,51])
print(t1) # 第一列是索引标签
# 0 1
# 1 2
# 2 21
# 3 31
# 4 41
# 5 51
# dtype: int64
# 索引也可以自行设置
t2 = pd.Series([1,2,21,31,41,51],index=list("abcdef"))
print(t2)
# a 1
# b 2
# c 21
# d 31
# e 41
# f 51
# dtype: int64
# 通过字典创建数组:字典的键对应索引
temp_dict = {
"name":"xiaohong","age":30,"tel":100}
t3 = pd.Series(temp_dict)
print(t3)
# name xiaohong
# age