Move from Excel to Python with Pandas Transcripts
Chapter: Data I/O (input and output)
Lecture: Demo: Multi-sheet Excel workbooks
0:00 We've used the simple to excel function in pandas to save a data frame as an
0:05 excel file. If we want to doom or complicated Excel file creation,
0:09 we're going to need to use Excel SX writer,
0:13 so you'll need to make sure you conduct install that before you continue with the rest
0:18 of this exercise. So when we save using XLs writer,
0:23 we need to create a writer object first.
0:27 In this example, we tell it to use Excel s ex writer as our output
0:31 engine. And we choose that because it gives us the flexibility to do additional formatting
0:37 of the Excel file. So now that we've defined this writer object because we have
0:46 to find the writer object now when we call Excel,
0:49 we pass it the writer object,
0:51 and that allows us to do things like to find a sheet name,
0:54 which will be useful. So in this case,
0:56 we're gonna have a sheet name called Sales Summary.
1:03 Also, by using writer, we can specify start rows and columns,
1:08 so we're gonna have the average displayed on the same sheet name as the sale summary
1:13 But we'll start over in column four so that the data doesn't overlap.
1:20 And here's an example of using a different sheet name,
1:22 so we would expect that our output is gonna have a single file with a sale
1:27 summary and a product summary tab.
1:29 And when we're done, if we want to say that you need to call writers
1:33 safe, I've opened up the file.
1:36 As you can see, it's called TPS Report,
1:38 and we have one day to frame.
1:40 Here we have our summary information starting in column E on the product summary tab.
1:46 We have the summary information for each of the products that was in the sales data
1:51 One of the things you will notice is that the formatting is not really nice
1:55 on this. The columns, for instance,
1:57 you want probably want to expand.
2:00 And then there's no number formatting,
2:02 so we can do that as well.