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: Bike ride duration

Solution: Bike ride duration

From the course: Faster pandas

Start my 1-month free trial

Solution: Bike ride duration

(upbeat music) - [Instructor] So let's take a look at the solution. We import SQLite, so we can connect to the database, and pandas, since we're going to use pandas, and we connect to the database with sqlite.connect, then we construct an SQL query. We select only the bike_id and the duration columns from the bike_rides table, where the year is 2017, and the month is smaller than four, meaning only the first quarter of the year. Then we use read_sql to load this data into a data frame. Next, we group by the bike_id, take the duration column, and take the 90% quantile. And finally, we sought in descending order, and take the first five values and print them out. Let's run it, python ride_duration.py, and we get five results. The highest is 124.6 and the lowest is 96.

Contents