My dataframe looks like
First Second A B A B 1 50 60 70 1002 20 5 10 303 35 45 60 50I want to add a new sub-column in each top-level column using .diff(), so it would look like (in this case, taking the differences of the B column)
First Second A B Diff A B Diff1 50 60 NaN 70 100 NaN2 20 5 -55 10 30 -703 35 45 40 60 50 20 I think that there should be a clean way to do this without for loops and other inefficient native python operations but I'm not sure how.