Home > Enterprise >  Removing the index reading from excel files with Pandas
Removing the index reading from excel files with Pandas

Time:04-05

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:

enter image description here

The 'index = False' is working with dealing with CSV files, what is possible to do on excel?

CSV example:

enter image description here

The excel file - enter image description here

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)

  • Related