I have a data frame with a hierarchical index in axis 1 (columns) (from a groupby.agg operation):
groupby.agg
USAF WBAN year month day s_PC s_CL
Following @jxstanford and @tvt173, I wrote a quick function which should do the trick, regardless of string/int column names:
def flatten_cols(df): df.columns = [ '_'.join(tuple(map(str, t))).rstrip('_') for t in df.columns.values ] return df