1. import numpy as np
    2. import pandas as pd
    1. s1 = pd.Series([1,2,3,4,5,6,7,8,9],
    2. index=['a','b','c','d','e','f','g','h','i'])
    3. s1
    1. a 1
    2. b 2
    3. c 3
    4. d 4
    5. e 5
    6. f 6
    7. g 7
    8. h 8
    9. i 9
    10. dtype: int64
    1. #普通索引获取数据
    2. s1[8]
    1. 9
    1. #整数数组索引获取数据
    2. s1[[1,3,5,7]]
    1. b 2
    2. d 4
    3. f 6
    4. h 8
    5. dtype: int64
    1. #布尔索引
    2. s1[s1>4]
    1. e 5
    2. f 6
    3. g 7
    4. h 8
    5. i 9
    6. dtype: int64
    1. s1[1:3]
    1. b 2
    2. c 3
    3. dtype: int64
    1. s1[-3:-1]
    1. g 7
    2. h 8
    3. dtype: int64
    1. #标签切片不遵循左闭右开规则
    2. s1['a' : 'd']
    1. a 1
    2. b 2
    3. c 3
    4. d 4
    5. dtype: int64

    相关函数见官网