1. Learn
  2. /
  3. Courses
  4. /
  5. Working with Dates and Times in Python

Exercise

How long between rides?

For your final exercise, let's take advantage of Pandas indexing to do something interesting. How much time elapsed between rides?

Instructions

100 XP
  • Calculate the difference in the Start date of the current row and the End date of the previous row and assign it to rides['Time since'].
  • Convert rides['Time since'] to seconds to make it easier to work with.
  • Resample rides to be in monthly buckets according to the Start date.
  • Divide the average by (60*60) to get the number of hours on average that W20529 waited in the dock before being picked up again.