I have a dataframe much like the one in this question: Pandas: drop a level from a multi-level column index?
cols = pd.MultiIndex.from_tuples([("a", "b"), ("a", "c")])
pd.DataFrame([[1,2], [3,4]], columns=cols)
a
---+--
b | c
--+---+--
0 | 1 | 2
1 | 3 | 4
In the question reference above, the questioner wanted to know how to drop the column heading a
. I would like to know how to drop it and all the columns underneath it (in this case b
) so that the resulting dataframe looks like:
| c
--+--
0 | 2
1 | 4
can you help me achieve this?