There are dfs with many thousands of columns, which are advisable to delete in a loop and provided they are completely empty. Wrote the code:
for n in df_balance.columns: if df_balance[n].any() == False: df_balance.drop(columns=df_balance.loc[:, n], inplace=True) but it gives an error:
KeyError: 'labels [nan nan nan ... nan nan nan] not contained in axis'
Tell me where was wrong.