Right now I have a dataframe named result with a multiindex that looks like the below:
col1 col2 bad1 bad2 col5
col3 col4
value value value value value
I would like to merge the first two columns and have been doing so like this:
result.columns = [' '.join(col).strip() for col in result.columns.values]
The above however returns this
col1 col2 bad1 col3 bad2 col4 col5
value value value value value
I would like the ability to pick which index value when I want so it would look more like this
col1 col2 col3 bad2 col5
value value value value value
So in the final result, i chose col3 and bad2 to be the column headers for the 3rd and 4th column.