a1
b2
b2
*****
a a1
dtype: object
*****
b b2
c c3
dtype: object
*****
c c3
b b2
dtype: object
t[t>4]#通过比较大小index取值
2 31
3 12
dtype: int64
print(t3.index)print(type(t3.index))#可迭代类型for i in t3.index:print(i)print("*"*5)print(list(t3.index)[:2])#可以跟列表一样操作print("*"*5)print(type(t3.values))#值是numpy.ndarray类型,object,也是可以切片遍历索引
Index(['a', 'b', 'c'], dtype='object')
<class 'pandas.core.indexes.base.Index'>
a
b
c
*****
['a', 'b']
*****
<class 'numpy.ndarray'>