Data Science Jumpstart with 10 Projects Transcripts
Chapter: Project 2: Excel Integration with Adult Income Data
Lecture: Create an Excel in Pandas with to_excel

Login or purchase this course to watch this video and the rest of the course contents.
0:00 I'm going to cheat a little bit. I'm going to load in a CSV file and then create an Excel file from that to simulate the Excel file that we're going to read from.
0:11 And then we'll show how to do some fancy exporting later on as well.
0:14 I'm importing my pandas library here and again I'm using data from University of California, Irvine.
0:22 This is a dataset about how much money people make. Let's read that in. In this case, if you look at what I just read in here,
0:36 you can see that this is actually not the data. This is information about the data.
0:43 This is just a file with information about the data, about what's going on there.
0:46 At the bottom of this you can see that there are the columns and some descriptions about the columns.
0:53 I'm going to take the column descriptions there and I'm going to use some Python code to split that out and make this names variable.
1:01 That's what it looks like.
1:03 It turns out that the data inside of this doesn't have column names, so I'm going to want to throw those column names on there.
1:09 Let's use read CSV to get that data. It turns out pandas can read from a URL. This is a single file, but I need to pass in the names there.
1:20 Let's look at our data frame after we do that. Here is our data frame. That looks pretty good. I'm just going to make a directory here.
1:30 I've already made it. I'm going to export this data as an Excel file. I just showed you how to write an Excel file. You just use toExcel.
1:39 That's a very basic way of doing it. Again, later on I'll show you how to do a little bit more complicated Excel exporting.


Talk Python's Mastodon Michael Kennedy's Mastodon