pandas之索引和切片3

对Series进行切片

s12['a':'f']
'''
a    3
s    1
d    9
f    9
dtype: int32
'''
s12[0:5]
'''
a    3
s    1
d    9
f    9
g    5
dtype: int32
'''
s12.loc['a':'d']
'''
a    3
s    1
d    9
dtype: int32
'''
s12.iloc[0:3]
'''
a    3
s    1
d    9
dtype: int32
'''

总结:loc都是左闭右闭,iloc都是左闭右开

你可能感兴趣的:(pandas之索引和切片3)