How to flatten a hierarchical index in pandas DataFrame columns in Python use join() and strip() Use DataFrame.columns.get_level_values()