Reputation: 43
I am sorry if the below question is very dumb. I am trying to write an array to file. I tried a few combinations and somehow was able to successfully do this. I don't fully understand how the below work but it works.
I have an array which has a shape (252, 200). When this writes to the file I get 252 columns and 200 rows. I want the 200 data in columns and the 252 data in row.
import xlsxwriter as xls
workbook = xls.Workbook('Lookback_Call.xlsx')
workbook = xls.Workbook('Lookback_Call.xlsx', {'nan_inf_to_errors': True})
worksheet = workbook.add_worksheet()
row = 0
for col, data in enumerate(tst1):
worksheet.write_column(row, col, data)
workbook.close()
Upvotes: 0
Views: 7980
Reputation: 41574
Try write_row()
instead of write_column()
:
for row, data in enumerate(tst1):
worksheet.write_column(row, 0, data)
Upvotes: 2
Reputation: 7211
Simply change
worksheet.write_column(row, col, data)
into
worksheet.write_column(col, row, data)
will work. This is a common issue when working with Excel. Excel name cells by "A2" to mean column A (first column) and row 2. Column goes first. This is like a convention in all Excel APIs.
Upvotes: 2