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