

002,pandas介绍


003,Series创建
导入Pandas

Series 是一种类似于一维数组的对象,由下面两个部分组成:
- values:一组数据(ndarray类型)
- index:相关的数据索引标签
(3.1)Series的创建
两种创建方式:
(1)由列表或Numpy数组创建
- 默认索引为0到N-1的整数型索引

- index和values


(2)由字典创建



04,Series显式索引和隐式索引
Series的索引
可以使用中括号取单个索引(此时返回的是元素类型),或者中括号里一个列表取多个索引(此时返回的仍然是一个Series类型)。分为显式索引和隐式索引:
(4.1)显式索引:
- 使用index中的元素作为索引值
- 使用.loc[] 推荐

(4.2)隐式索引
- 使用整数作为索引值
- 使用.iloc[] (推荐)


05,Series显式切片和隐式切片


06,Series基本属性和方法
(6.1)基本属性
- shape 形状
- size 长度
- index 索引
- value 值
- name 名字

(6.2)head()和tail()方法
- head() 查看前几条数据,默认5条
- tail() 查看后几条数据,默认5条

(6.3)检测缺失数据
- pd.isnull()
- pd.notnull()
- isnull()
- notnull()


(6.4)使用bool值索引过滤数据
第1种方法

第2种方法

07,Series的运算
(7.1)适用于Numpy的数组运算也适用于Series


(7.2)Series之间的运算
- 在运算中自动对齐索引
- 如果索引不对应,则补NaN
- Series没有广播机制




如果 s4的索引不是[0,1,2,3],还是根据对应索引的值进行运算
- 注意:要想保留所有的index,则需要使用.add()函数

总结:
- Series:可以看做是一个有序的字典结构