I am using multi index dataframe with mixed index labels i.e. first level contains string labels, 2nd and 3rd level are integer labels and 4th level labels are dates. Dataframe looks like below (master_df)
X1 X2 X3
bucket Start Stop Date
B1 1 1 1/3/2000 2 2 3
1/4/2000 4 3 3
B1 1 2 1/3/2000 4 2 3
1/4/2000 6 2 2
I want to take out sub_df as master_df.ix['B1',1,2,:], do some operations on sub_df and store it back into master_df at the same location. I am able to take out sub_df using various methods, but when comes to storing it back, all the options I have tried dont seem to be working. I guess this issue is related to having 'Integer' labels(at 2nd and 3rd lavel - start-stop). I have tried below options/methods without any success
sub_df = master_df.ix['B1'].ix[1].ix[2]
#do some operations on sub_df
master_df.xs('B1').xs(1).xs(2).update(sub_df)
master_df.ix['B1'].ix[1].ix[2].update(sub_df)
merge(master_df.ix['B1',1,2,:],sub_df)
none of the above operations reflect changes in master_df (i dont get any error messages either.)
Can you suggest proper way to do it?
Update :
sub_df and master_df do not have same index as operations on sub_df expect date index only. sub_df look like below.
X1 X2 X3
Date
1/3/2000 2 2 3
1/4/2000 4 3 3
If I try
sub_df = master_df[master_df.index.get_loc(('B1', 1, 2))]
I get following error -
TypeError: unhashable type: 'numpy.ndarray'
Main purpose here is to operate on only small chunk of master_df and store those results back at original location in master_df. I tried using update method, however any other alternative to achive this purpose will do.