文章作者:Tyan
博客:noahsnail.com  |  CSDN  |  简书
| 1 | # pandas是一个用来进行数据分析的基于numpy的库 | 
0       3
1       5
2    test
3      -5
4     0.3
dtype: object
| 1 | # 用list, index构建Series | 
A       3
B       5
C    test
D      -5
E     0.3
dtype: object
| 1 | # 通过dict构建Series | 
Alibaba     500
Baidu       400
Jingdong    300
Tecent      600
dtype: int64
| 1 | # Series数据选择 | 
400
Baidu     400
Tecent    600
dtype: int64
| 1 | # 根据条件选择数据 | 
Baidu       400
Jingdong    300
dtype: int64
| 1 | # 条件选择原理 | 
Alibaba     False
Baidu        True
Jingdong     True
Tecent      False
dtype: bool
Baidu       400
Jingdong    300
dtype: int64
| 1 | # Series元素赋值 | 
old value:  400
new value:  450
| 1 | # 根据条件赋值 | 
old series: 
Alibaba     500
Baidu       400
Jingdong    300
Tecent      600
dtype: int64
new series: 
Alibaba     500
Baidu       500
Jingdong    500
Tecent      600
dtype: int64
| 1 | # Series数学运算 | 
Division: 
Alibaba     250.0
Baidu       250.0
Jingdong    250.0
Tecent      300.0
dtype: float64
Square: 
Alibaba     250000
Baidu       250000
Jingdong    250000
Tecent      360000
dtype: int64
Alibaba     250000
Baidu       250000
Jingdong    250000
Tecent      360000
dtype: int64
| 1 | # 定义新的Series, 公司人数 | 
Alibaba     45000
Baidu       50000
Jingdong    80000
Netease     30000
Tecent      60000
dtype: int64
| 1 | # Series相加, series3没有Netease, 因此结果为NaN | 
Alibaba     45500.0
Baidu       50500.0
Jingdong    80500.0
Netease         NaN
Tecent      60600.0
dtype: float64
| 1 | # 判断数据是否数据缺失 | 
False
True
| 1 | # 找出数据为null或非null的元素 | 
Alibaba      True
Baidu        True
Jingdong     True
Netease     False
Tecent       True
dtype: bool
Alibaba     False
Baidu       False
Jingdong    False
Netease      True
Tecent      False
dtype: bool
Netease   NaN
dtype: float64
Alibaba     45500.0
Baidu       50500.0
Jingdong    80500.0
Tecent      60600.0
dtype: float64
 
          