Home > other >  Pandas to_excel command, determine target column
Pandas to_excel command, determine target column

Time:12-19

This block takes a vector DATA and writes it as the first column of an excel sheet

wf = pd.DataFrame({'first column': DATA})
wf.to_excel(f"MyExcelSheet.xlsx", index=False)

How should I change this so that DATA is written as the second column instead?

CodePudding user response:

You could try adding a start column offset:

wf.to_excel('MyExcelSheet.xlsx', startcol=1, index=False)

(defaults starting column in 0)

See panda docs for more options.

  • Related