How to remove the unnamed column? I know that with csv files
Code:
import numpy as np
import pandas as pd
df.to_excel('Excel_Sample2.xlsx', sheet_name = 'NewSheet',index = False)
Result:
The 'index = False' is working with dealing with CSV files, what is possible to do on excel?
CSV example:
CodePudding user response:
I reproduced your error - from my side, I see "Unnamed: 0" because your cell A1 in your excel sheet is empty... I believe if you check that first cell in your dataframe before exporting to Excel , you should see the issue
df.columns[0]
CodePudding user response:
You forgot to add .csv
while saving the file. Try:
df.to_csv('My_Output.csv', index=False)