From the course: Faster pandas

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Challenge: Query a DataFrame

Challenge: Query a DataFrame

From the course: Faster pandas

Start my 1-month free trial

Challenge: Query a DataFrame

(upbeat music) - [Instructor] We have a data of bike rides in a CSV and we'd like to find out how many rides in 2016 were in the afternoon of a weekend or a holiday. We defined the afternoon as a time between noon to 6:00 PM, the weekend is Saturday or Sunday and the holidays, we have a list of holidays. So this is the holiday list and we have your field function to load the data frame. We've one function that checks if it's 2016, another one to check if we were the weekend, another one for the holiday, another one for the afternoon. And finally the vacation rides we iterate of every row in the data frame, check if you're in 2016. And then if you're in holiday and an afternoon, then we append the result and we turn it eventually. Let's write up. So, ipython, we're going to run our code, so run vacation rides. And then DF equal load, DF of the Austin dataset. Let's see how many we have, so len of vacation ride of the data frame, 420 rides. I'm going to use the time, instead of time…

Contents