From the course: Data Analysis with Python and Pandas

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Solution: Importing and exporting Excel data

Solution: Importing and exporting Excel data

From the course: Data Analysis with Python and Pandas

Solution: Importing and exporting Excel data

- [Instructor] All right, everybody. Our solution code is up on the right. Let's go ahead and dive into the notebook. All right, so the first thing that we need to do is set up our Excel writer. So we're going to write to a workbook called DataForChandler.xlsx. And then before we start writing out sheets, I'm actually going to set up a little for loop inside this writer, and I'm just going to loop through the years in this range. So our first year was 2013, so this will start my range. And our last year was 2017. So we need to go one pass this because our stop point is not inclusive to 2018, and this will generate the integers 2013 through 2017. And so for each pass through this loop, we're going to filter our data frame. We're extracting the year portion of our date. We'll filter down to the specific year we're looping through, and then we're going to write that data frame out to a sheet with the string of the year as the name. So our sheet name will be 2013 as a string, and we'll…

Contents