LoslegenKostenlos loslegen

How long per weekday?

Pandas has a number of datetime-related attributes within the .dt accessor. Many of them are ones you've encountered before, like .dt.month. Others are convenient and save time compared to standard Python, like .dt.day_name().

Diese Übung ist Teil des Kurses

Working with Dates and Times in Python

Kurs anzeigen

Anleitung zur Übung

  • Add a new column to rides called 'Ride start weekday', which is the weekday of the Start date.
  • Print the median ride duration for each weekday.

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# Add a column for the weekday of the start of the ride
rides['Ride start weekday'] = rides['Start date'].____

# Print the median trip time per weekday
print(rides.____(____)['Duration'].median())
Code bearbeiten und ausführen