I have time-series DataFrame df that looks like this:
time A B C D E 2011-01-04 15:55:00 0.003452 0.005303 0.016632 0.009611 0.000726 ... 2011-01-04 15:56:00 0.004292 0.064709 0.012159 0.020398 0.000272 ... 2011-01-04 15:57:00 0.006617 0.009344 0.018512 0.029696 0.001235 ... 2011-01-04 15:58:00 0.005883 0.048564 0.020213 0.072104 0.001337 ... 2011-01-04 15:59:00 0.008602 0.047318 0.024568 0.051225 0.002775 ... I want to add a multiindex header to categorize each columns. So for instance, I want to group column A and B into group 1 and C and D into group 2 and E in group 3. Therefore I would have:
group 1 1 2 2 3 time A B C D E 2011-01-04 15:55:00 0.003452 0.005303 0.016632 0.009611 0.000726 ... 2011-01-04 15:56:00 0.004292 0.064709 0.012159 0.020398 0.000272 ... 2011-01-04 15:57:00 0.006617 0.009344 0.018512 0.029696 0.001235 ... 2011-01-04 15:58:00 0.005883 0.048564 0.020213 0.072104 0.001337 ... 2011-01-04 15:59:00 0.008602 0.047318 0.024568 0.051225 0.002775 ... How can I do so with a conditional statement (if column == 'A' | 'B' then assign to group 1, etc...)?