I used to_flat_index()
to flatten columns and ended up with column names like ('Method', 'sum')
. I am trying to remove the special characters from these. But when I try to remove them, it changes all the column names to nan
function attempted:
df_pred.columns = df_pred.columns.str.replace("[(,),']", '')
Expected outcome: MethodSum