I have this problem where I am able to write Pandas dataframe into excel using openpyxl and it works fine where the dataframe is written vertically.( Same column, consecutive rows)
but I want to write my dataframe horizontally i.e. elements in same row, consecutive columns
My dataframe is a single dimensional one like [10, 9,8,7,6]
writer = pd.ExcelWriter(fn, engine='openpyxl')
writer.book = book
writer.sheets = dict((ws.title, ws) for ws in book.worksheets)
#df.to_excel(writer, sheet_name='Sheet1', header=None, index=False)
df_2.to_excel(writer, sheet_name='Sheet3', header=None, index=False,
startcol=1,startrow=1)
writer.save()
My question is:
Can we define into this code snippet whether the data frame should be written vertically or horizontally just like startrow and startcol.
I've searched everywhere but could not find any.