Reputation: 79
I am importing an excel sheet using openpyxl so that I can retain the formulas. When I re-write to a new file, the dataframe output is adding an index column and an index row. I know that index=False will remove the column, but how do I remove the row? Picture added to illustrate.
https://i.sstatic.net/eblu5.png
This is the code I'm using. Is there another command like index=False to remove the top row index?
import pandas as pd
from openpyxl import load_workbook
from openpyxl.utils.dataframe import dataframe_to_rows
df = pd.DataFrame()
wb = load_workbook(filename = importfile)
sheet_names = wb.sheetnames
name = sheet_names[1]
sheet_ranges = wb[name]
df = pd.DataFrame(sheet_ranges.values)
df.to_excel(savefile, index=False)
Upvotes: 1
Views: 1024