I am trying to read all files from a folder to drop unwanted variables and export the files to a different location not to override the existing files. But I get the below error. Any help is much appreciated.
Below is the code I am using:
from pathlib import Path
folder = (r"C:\Users\Mand\Documents")
col_to_delete = ['Col1', 'Col2', 'Col3', 'Col4']
for file in Path(folder).glob('*.xlsx'):
    df = pd.read_excel(file)
    df = df.drop(labels = col_to_delete, axis=1, inplace = True)
    
df.to_excel(file.with_suffix('.xlsx'),index = False)
Below is the error I get:
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-33-8a2ee75be42d> in <module>
      8     **df = df.drop(labels = col_to_delete, axis=1, inplace = True)**
      9 
---> 10 df.to_excel(file.with_suffix('.xlsx'),index = False)
     11 
**AttributeError:** 'NoneType' object has no attribute 'to_excel'
