Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set the default subtitles language in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Working With Excel Files

00:00 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 sheet_name.

00:29 Here, you create a file with a worksheet called COUNTRIES that stores the data. The optional parameters startrow and startcol both default to 0 and indicate the upper-leftmost cell where the data should start being written into the Excel spreadsheet.

01:01 Here, you specify that the table should start in the third row and the fifth column. Remember, you’re using zero-based indexing, so the third row is denoted by 2 and the fifth column by 4.

01:14 Here’s what the resulting worksheet looks like. read_excel() also has the optional parameter sheet_name that specifies which worksheets to read when loading data.

01:26 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.

01:43 Here’s an example of how you’d use this parameter.

01:55 The argument 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 read_excel() and .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.

02:26 Next up, working with file-based SQL databases.

Become a Member to join the conversation.