pandas has support for multi-level column names:
>>> x = pd.DataFrame({\'instance\':[\'first\',\'first\',\'first\'],\'foo\':[\'a\',\'b
No need to create a list of tuples
Use: pd.MultiIndex.from_product(iterables)
import pandas as pd
import numpy as np
df = pd.Series(np.random.rand(3), index=["a","b","c"]).to_frame().T
df.columns = pd.Multiindex.from_product([["new_label"], df.columns])
Resultant DataFrame:
new_label
a b c
0 0.25999 0.337535 0.333568
Pull request from Jan 25, 2014