Data Science Jumpstart with 10 Projects Transcripts
Chapter: Project 9: SQL / Database Integration
Lecture: Query a SQLite table with Pandas

Login or purchase this course to watch this video and the rest of the course contents.
0:00 In this section we're going to look at doing another query that's not just selecting star from a database. Let's run this query
0:07 I'm just going to say select star from alt over year is 1990 and it looks like we have the values from 1990 there
0:15 so I mentioned previously when I was teaching about describe someone was upset because
0:19 They implemented describe on their database and it took them like three weeks to do that
0:25 So I'd prefer to just pull the data out and use pandas to do that. Let's see how we can do that Okay, so I'm gonna read my data here
0:33 Here is my data select star from Alta and I just do an Alta describe
0:37 Since I've sucked it into pandas I can get those summary statistics relatively easily
0:42 Now if I wanted to do a describe query, it would look something like this This isn't even a complete describe query, but it looks something like this
0:53 And we can run that this is doing this for just one column This is the snow depth column how much snow is on the ground?
0:59 You can imagine doing that for multiple columns is sort of a pain Now note that I can't even do standard deviation in SQL lite some
1:10 Databases have support for that but I can do something like this. This is kind of cool
1:14 I can say let's create an aggregate called standard deviation, which is this Python?
1:21 Standard deviation. It's this class and then I can actually come in here and run SQL and
1:27 Tell it to run that standard deviation this example. I showed how we can pull data out and process it in pandas
1:34 Hopefully that makes sense. Can you stick processing into a database? Yeah, you can
1:39 I showed how to calculate the standard deviation in SQL lite in practice that tends to be not so much of a problem because people
1:45 Don't switch out their database too much But oftentimes you do want to push calculation into your database. You can use Python to do that
1:53 It's not going to be particularly fast to do that, but it is an option if you need at least for SQL lite


Talk Python's Mastodon Michael Kennedy's Mastodon