I have a pandas dataframe with a structure like:
| id | (A, dog) | (A,cat) | (B, dog) | (B, cat) |
|---:|---------:|--------:|---------:|----------|
|  1 |        1 |       2 |        3 |          |
|  2 |        4 |       5 |        6 |          |
|  3 |        7 |       8 |        9 |          |
which df.columns = Index([(A, dog) (A,cat), (B, dog),(B, cat)])
And I would like to transform it into:
|    | A         | B         |
| id | dog | cat | dog | cat |
|----|-----|-----|-----|-----|
|  1 |   1 |   2 |   3 |     |
|  2 |   4 |   5 |   6 |     |
|  3 |   7 |   8 |   9 |     |
with df.columns = MultiIndex([(A, dog) (A,cat), (B, dog),(B, cat)])
How can I do that?
I've tried with pd.set_index
