Pandas to_excel command, determine target column

Question:

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?

Asked By: In the blind

||

Answers:

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.

Answered By: XaC
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.