adding a row to a MultiIndex DataFrame/Series

You have to specify a tuple for the multi-indexing to work (AND you have to fully specify all axes, e.g. the : is necessary)

In [26]: df.ix[(dt.datetime(2013,2,3,9,0,2),0),:] = 5

In [27]: df
Out[27]: 
                          vals
Time                hsec      
2013-02-03 09:00:01 1       45
                    25      46
2013-02-03 09:00:02 0        5

Easier to reindex and/or concat/append a new dataframe though. Generally setting (with this kind of enlargement), only makes sense if you are doing it with a small number of values. As this makes a copy when you do this.


Update since .ix is deprecated: Use [DataFrame.loc][1] instead:

# say you have dataframe x
x
Out[78]: 
              a    b       time
indA indB                     
a    i      0.0  NaN 2018-09-12
b    j      1.0  2.0 2018-10-12
c    k      2.0  3.0 2018-11-12
     f      NaN  NaN        NaT
d    i      5.0  NaN        NaT

x.loc[('a','k'),:] = (3.5,6,pd.NaT)

x
Out[80]: 
              a    b       time
indA indB                     
a    i      0.0  NaN 2018-09-12
b    j      1.0  2.0 2018-10-12
c    k      2.0  3.0 2018-11-12
     f      NaN  NaN        NaT
d    i      5.0  NaN        NaT
a    k      3.5  6.0        NaT