Working With Excel Files
Working with Excel files. You’ve already learned how to read and write Excel files with pandas. However, there are a few more options worth considering. For one, when you use
.to_excel(), you can specify the name of the target worksheet with the optional parameter
Here, you create a file with a worksheet called
COUNTRIES that stores the data. The optional parameters
startcol both default to
0 and indicate the upper-leftmost cell where the data should start being written into the Excel spreadsheet.
It can take one of the following values: the zero-based index of the worksheet, the name of the worksheet, a list of indices or names to read multiple sheets, and the value
None to read all sheets.
parse_dates=['IND_DAY'] tells pandas to try to consider the values in this column as dates or times. There are other optional parameters you can use with
.to_excel() to determine the Excel engine, specify data types, specify the strings that will be interpreted by pandas as
nan values, and the parsing of dates, amongst others.
Become a Member to join the conversation.