BUG/API: assignment of frame in a multi-indexed column frame with a matching level (original) (raw)

http://stackoverflow.com/questions/24553921/pandas-matching-on-level-of-hierarchical-index/24554350#24554350

This should align on the columns axis. Not clear how to specify the alignment level though (e.g. broadcasting would be tricky here).

import numpy as np
import pandas as pd

arrays = [np.hstack([ ['one']*3, ['two']*3]), ['Dog', 'Bird', 'Cat']*2]
columns = pd.MultiIndex.from_arrays(arrays, names=['foo', 'bar'])

df = pd.DataFrame(np.zeros((3,6)),columns=columns,
                  index=pd.date_range('20000103',periods=3))

df['one'] = pd.DataFrame({'Bird' : np.ones(3)*2,
                          'Dog' : np.ones(3),
                          'Cat' : np.ones(3)*3},
                          index= pd.date_range('20000103',periods=3))
df['two'] = pd.DataFrame({'Dog' : np.ones(3)*4,
                          'Bird' : np.ones(3)*5,
                          'Cat' : np.ones(3)*6,},
                          index= pd.date_range('20000103',periods=3))