I'm using a dynamic script to remove columns with values equal to column name. Example below for table named summ.
Script:
for col in range(0, len(summ.columns)-1):
if len(summ[(summ[summ.columns[col]].astype(str).str.lower() == summ.columns[col])]) == len(summ):
summ = summ.drop(columns = summ.columns[col])
Output of the script after executing the for loop script above:
Once I re-run the script above, it would also delete the lname column but why does the for loop not check all columns?