I would like to create an empty DataFrame with a MultiIndex before assigning rows to it. I already found that empty DataFrames
The solution is to leave out the labels. This works fine for me:
>>> my_index = pd.MultiIndex(levels=[[],[],[]],
labels=[[],[],[]],
names=[u'one', u'two', u'three'])
>>> my_index
MultiIndex(levels=[[], [], []],
labels=[[], [], []],
names=[u'one', u'two', u'three'])
>>> my_columns = [u'alpha', u'beta']
>>> df = pd.DataFrame(index=my_index, columns=my_columns)
>>> df
Empty DataFrame
Columns: [alpha, beta]
Index: []
>>> df.loc[('apple','banana','cherry'),:] = [0.1, 0.2]
>>> df
alpha beta
one two three
apple banana cherry 0.1 0.2
Hope that helps!