Making timedelta columns
Earlier in this course, you wrote a loop to subtract datetime objects and determine how long our sample bike had been out of the docks. Now you'll do the same thing with Pandas.
rides has already been loaded for you.
Diese Übung ist Teil des Kurses
Working with Dates and Times in Python
Anleitung zur Übung
- Subtract the
Start datecolumn from theEnd datecolumn to get a Series of timedeltas; assign the result toride_durations. - Convert
ride_durationsinto seconds and assign the result to the'Duration'column ofrides.
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
# Subtract the start date from the end date
ride_durations = ____ - ____
# Convert the results to seconds
____[____] = ride_durations.____
print(rides['Duration'].head())