Exercise

Back to the future

A new update to the data pipeline feeding into the ride_sharing DataFrame has been updated to register each ride's date. This information is stored in the ride_date column of the type object, which represents strings in pandas.

A bug was discovered which was relaying rides taken today as taken next year. To fix this, you will find all instances of the ride_date column that occur anytime in the future, and set the maximum possible value of this column to today's date. Before doing so, you would need to convert ride_date to a datetime object.

The datetime package has been imported as dt, alongside all the packages you've been using till now.

Instructions

100 XP
  • Convert ride_date to a datetime object using to_datetime(), then convert the datetime object into a date and store it in ride_dt column.
  • Create the variable today, which stores today's date by using the dt.date.today() function.
  • For all instances of ride_dt in the future, set them to today's date.
  • Print the maximum date in the ride_dt column.