0

I use the following code to move data from one Excel file to another.

import pandas as pd
inventory = pd.read_excel('Original_File.xlsx', skiprows=3)
inventory.to_excel('New_File.xlsx')

How do I NOT write the content in column 1 to the new Excel file? Column 1 contains a blank column header then a row number for each line of data in the dataframe.

  • 1
    Does this answer your question? [Export from pandas to\_excel without row names (index)?](https://stackoverflow.com/questions/22089317/export-from-pandas-to-excel-without-row-names-index) – Karthik Sep 08 '20 at 18:33

1 Answers1

0

Problem

By default, to_excel write row names (index) out.

Solution

when you call to_excel, you can skip the row name by setting parameter index as False:

inventory.to_excel('New_File.xlsx', index=False)

Reference

https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.to_excel.html

yibo
  • 517
  • 3
  • 10