def flattenHierarchicalCol(col,sep = '_'):
if not type(col) is tuple:
return col
else:
new_col = ''
for leveli,level in enumerate(col):
if not level == '':
if not leveli == 0:
new_col += sep
new_col += level
return new_col
ds1.columns = ds1.columns.map(flattenHierarchicalCol)
ds1.reset_index(inplace=True)