ProfessorLeVesseur commited on
Commit
1544322
·
verified ·
1 Parent(s): 6fca1e5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -141,8 +141,11 @@ def main():
141
  # Read the Excel file into a DataFrame
142
  # df = pd.read_excel(uploaded_file)
143
 
144
- # Read the Excel file into a DataFrame and handle duplicate columns automatically
145
- df = pd.read_excel(uploaded_file, mangle_dupe_cols=True)
 
 
 
146
 
147
  # Replace student names with initials
148
  df = replace_student_names_with_initials(df)
 
141
  # Read the Excel file into a DataFrame
142
  # df = pd.read_excel(uploaded_file)
143
 
144
+ # Rename duplicate columns to make them unique
145
+ cols = pd.Series(df.columns)
146
+ for dup in cols[cols.duplicated()].unique():
147
+ cols[cols[cols == dup].index.values.tolist()] = [f"{dup}_{i+1}" if i != 0 else dup for i in range(sum(cols == dup))]
148
+ df.columns = cols
149
 
150
  # Replace student names with initials
151
  df = replace_student_names_with_initials(df)