question 442 Data Formats & Analytical Workflows · easy
The cache that forgets timestamps
busiest_hour_cached saves trips to a cache file, reads the cache back, and returns the pickup hour with the most trips (the earliest hour on a tie). The trips it receives have a real datetime column, yet it crashes with AttributeError: Can only use .dt accessor with datetimelike values. Fix the cache so the types survive.
Function
busiest_hour_cached(trips, path)tripsa DataFrame whose
pickup_at column is already a datetimeReturnsan int hour