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().
Deze oefening maakt deel uit van de cursus
Working with Dates and Times in Python
Oefeninstructies
- Add a new column to
ridescalled'Ride start weekday', which is the weekday of theStart date. - Print the median ride duration for each weekday.
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
# 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())