data = pd.Series(np.random.randn(10),index=[
[‘a’,’a’,’a’,’b’,’b’,’b’,’c’,’c’,’d’,’d’],
[1,2,3,1,2,3,1,2,2,3]
])
print(data)
print(data.index)data = pd.Series(np.random.randn(10),index=[
[‘a’,’a’,’a’,’b’,’b’,’b’,’c’,’c’,’d’,’d’],
[1,2,3,1,2,3,1,2,2,3]
])
print(data)
print(data[‘b’])data = pd.Series(np.random.randn(10),index=[
[‘a’,’a’,’a’,’b’,’b’,’b’,’c’,’c’,’d’,’d’],
[1,2,3,1,2,3,1,2,2,3]
])
print(data)
print(data[‘b’])
print(data[:,2])
pandas层次化索引
最新推荐文章于 2024-06-13 17:43:07 发布