tuples = list(zip(*[['one', 'one', 'two', 'two', 'three', 'three'], ['foo',
    'bar', 'foo', 'bar', 'foo', 'bar']]))
index = pd.MultiIndex.from_tuples(tuples, names=['first', 'second'])
df = pd.DataFrame(np.random.randn(3, 6), index=['A', 'B', 'C'], columns=index)
Performing arithmetic with a multi-index pandas dataframe that needs broadcasting at several levels