I have a dataframe which its column names have changed to
MultiIndex([( 'ID', ''),
('Probability', 'mean'),
('Probability', 'median'),
('Uncertainty', 'mean'),
('Uncertainty', 'median')],
)
because I did
data[data["ID"].notnull()].groupby(["ID"]).agg({"Probability":["mean", "median"], "Uncertainty":["mean", "median"]}).reset_index()
I want to rename the column names to something like this:
["ID", "Probability_mean", "Probability_median", "Uncertainty_mean", "Uncertainty_median"]
I can rename each original column name individually but I can't rename them together. I also tried flattening the dataframe as I thought it was a multi index or a multilevel. Although it looks so, it is not one. Most of the multi index functionalities don't work for it. Is there a way to rename these columns? Am I missing something?