How to solve 'The column label 'Avg_Threat_Score' is not unique.'? suing pandas
问题 When running the code I am facing following error. error - The column label 'Avg_Threat_Score' is not unique. I was creating a pivot table and wanted to sort the value from high to low. pt = df.pivot_table(index = 'User Name',values = ['Threat Score', 'Score'], aggfunc = { 'Threat Score': np.mean, 'Score' :[np.mean, lambda x: len(x.dropna())] }, margins = False) new_col =['User Name Count', 'AVG_TH_Score', 'Avg_Threat_Score'] pt.columns = [new_col] #befor this code is working, after that now