I have a table which is similar as shown below :
| OpenTable | ||
|---|---|---|
| One | Two | Three |
| A | B | C |
| Four | Five | Six |
| D | E | F |
When I read it in pandas with df = pd.read_excel('myfilename.xlsx') function. I used pandas to remove the Nan values from a particular column.
It adds headers names to the empty headers like below:
| OpenTable | Unnamed: 1 | Unnamed: 2 |
|---|---|---|
| One | Two | Three |
| A | B | C |
| Four | Five | Six |
| D | E | F |
When I export this file using df.to_excel('my filename.xlsx')
It still retains the headers as below, Is there any way to ignore those and write to excel?
CodePudding user response:
df.to_excel('my fillename.xlsx', header=['OpenTable', '', ''])
