【发布时间】:2021-12-29 19:36:49
【问题描述】:
s2 = pd.Series([10,20,30,40,50,60], index=['a', 'b', 'c', 'd', 'e', 'f'])
当我使用如下标签选择切片时
print(s2['b':'e'])
输出是
b 23
c 33
d 43
e 54
dtype: int64
但是当我使用下面的索引选择切片时
print(s2[1:4])
输出是
b 23
c 33
d 43
dtype: int64
为什么当我们用索引选择时,它是用 step-1 选择的,而用标签它也是选择最终标签?
【问题讨论】:
标签: python pandas indexing slice