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.

Solution: Query a DataFrame

Solution: Query a DataFrame

From the course: Faster pandas

Start my 1-month free trial

Solution: Query a DataFrame

(bright music) - [Instructor] Let's have a look at the solution. I'm inputting Saturday and Sunday from the calendar, and then, when I'm loading the data frame, I'm going to combine the checkout date and the checkout time plus single column called time, which will be pandas, the timestamp object, and then, here's the function to do the vacation rides. I have one mask, which is where the year is 2016. Another mask checking if it's a holiday or it's a weekend, and another mask checking if we're in the afternoon. And finally, I'm returning the data frame with all masks are ended together. Let's have a look. So ipython. We're going to run our code, vacation rides, and then, we're going to load the data frame, and let's check. So length of vacation rides of the data frame, and we get the same result as before. Always check your optimized code to see that it's correct. And now, we can use the timeit, timeit to see how much time it takes, and 7.68 millisecond. Before we had 10.7 seconds…

Contents