I'm trying to add another line of headers above the headers in a pandas dataframe.
Turning this :
import pandas as pd
df = pd.DataFrame(data={'A': range(5), 'B': range(5), 'C':range(5)})
print(df)
A B C
0 0 0 0
1 1 1 1
2 2 2 2
3 3 3 3
4 4 4 4
into this (for instance):
D E
A B C
0 0 0 0
1 1 1 1
2 2 2 2
3 3 3 3
4 4 4 4
Having both A and B under D and C under E. This doesn't seem like something that would be hard with pandas but yet I can't seem to find the answer. How do you do this?