I would like to add a column SUM to the df1 below. It's a Datetime MultiIndex and the new column SUM should return the sum of the price row.
multex = pd.MultiIndex.from_product([['price',
'weight','quantity','portfolio'] ,df1.index],names=['Date', 'Stats'])
new_df = pd.DataFrame(index=multex, columns= df1.columns.values.tolist())
Subsequently would like to add a row SUM as well that returns the same value. I've tried the following so far:
df1['SUM']= df1.ix['price'].sum(axis=1)
A B C D E
2006-04-28 00:00:00
price 69.62 69.62 6.518 65.09 69.62
weight
std
2006-05-01 00:00:00
price 71.5 71.5 6.522 65.16 71.5
weight
std
2006-05-02 00:00:00
price 72.34 72.34 6.669 66.55 72.34
weight
std
df1['SUM']= df1.ix['price'].sum(axis=1)