I have a multi-indexed pandas dataframe that looks like this (snippet):
Smad3_pS423/425_customer 0 1 0.664263
2 0.209911
3 0.099809
5 1 0.059652
2 0.190174
3 0.138850
a-Tubulin 0 1 0.072436
2 0.068282
3 0.087989
5 1 0.083960
2 0.076102
3 0.068119
The output of df.index is (with the labels
bit shortened for viewing purposes):
MultiIndex(levels=[[u'Customer_Col1A2', u'Smad2_pS465/467 customer', u'Smad3_pS423/425_customer', u'Smad4_customer', u'Smad7_customer', u'a-Tubulin'], [u'0', u'10', u'120', u'180', u'20', u'240', u'30', u'300', u'45', u'5', u'60', u'90'], [u'1', u'2', u'3']],
labels=[[2, 2, 2, 2, 2, 2, 2, ... more_labels...]],
names=[u'Antibody', u'Time', u'Repeats'])
My question is, what is the best way to divide the a-tubulin
data entry by the Smad3_pS423/425_customer
entry?
One cumbersome method is:
ab=[]
for i in self.data.index.get_level_values('Antibody'):
ab.append(i)
antibodies= list(set(ab))
for i in antibodies:
print self.data.loc[i]/self.HK
But this doesn't seem like the pandas
way of doing this. Does anybody know of an easier way to do this? (I suspect pandas
might have built in a one liner to do this).
Thanks