Move from Excel to Python with Pandas Transcripts
Chapter: Data I/O (input and output)
Lecture: Demo: Complex Excel saves

Login or purchase this course to watch this video and the rest of the course contents.
0:00 we're gonna do is we're gonna create some additional cells to do the formatting for us
0:04 So what this code does is it uses the writer object that we created here
0:16 toe pull out the workbook and then from the workbook were accessing the sales summary
0:22 worksheet. And the first thing we need to do is add a number format,
0:25 and in this case, you use a dictionary,
0:28 What you want to call it,
0:29 and I want to call this numb format.
0:31 I'm setting a comma so that the numbers are formatted as decimals with commas.
0:37 And this uses thesis, aim formatting structure you would use within excel.
0:41 And then let's add another. So and now we need to apply the formatting.
0:46 So on our worksheet in this example now we are saying for each of the columns
1:01 in the sales summary columns a through B,
1:04 we want to be with 18 see,
1:07 we want with a team. But we also want to apply the number format and
1:12 columns ether G. We want to be a little bit narrower,
1:15 but also have the number format.
1:17 Now, if we want to get worksheet number two so we've done a similar set
1:30 of instructions for the product. Summary tab primarily defined products Summary up here Now we're
1:35 saying a three D need to be numeric columns and the in the format we defined
1:41 and need to have a width of 16.
1:43 So let's rerun all of this and see what our new file looks like.
1:51 Now this looks a lot nicer.
1:53 So I just open up the file and did not do any formatting.
1:56 The columns are wide so you can see all your data.
1:59 There are decimal points and commas,
2:02 and we have two decimal points for all of our numbers.
2:04 And you can see there does it on the second page as well.
2:08 And the reason I wanted to go through this is as you start to output Excel
2:12 This is probably the format you're gonna share with others.
2:16 So it's really important that you have this capability toe format it in a way that