import pandas as pd import numpy as np df = pd.DataFrame(np.zeros([4,1]), index=pd.MultiIndex.from_product([[0,1], [\'a\',\'b\']])) df.loc[(slice(None), \'a\'), 0] = pd