First page Back Continue Last page Overview Image

Hierarchical Indexing

Advanced or multi-level indexing for working with higher dimensional data is available both for Series and for DataFrames.

import pandas as pd

import numpy as np

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)

a 1 -0.075698

2 -0.533536

3 -0.741319

b 1 -0.397259

2 -0.400656

3 -1.288675

c 1 0.314690

2 -0.722720

d 2 -0.265628

3 -1.746036

dtype: float64