How many joyrides?
Suppose you have a theory that some people take long bike rides before putting their bike back in the same dock. Let's call these rides "joyrides".
You only have data on one bike, so while you can't draw any bigger conclusions, it's certainly worth a look.
Are there many joyrides? How long were they in our data set? Use the median instead of the mean, because we know there are some very long trips in our data set that might skew the answer, and the median is less sensitive to outliers.
Diese Übung ist Teil des Kurses
Working with Dates and Times in Python
Anleitung zur Übung
- Create a Pandas Series which is
True
whenStart station
andEnd station
are the same, and assign the result tojoyrides
. - Calculate the median duration of all rides.
- Calculate the median duration of
joyrides
.
Interaktive Übung
Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.
# Create joyrides
joyrides = (rides[____] == rides[____])
# Total number of joyrides
print("{} rides were joyrides".format(joyrides.sum()))
# Median of all rides
print("The median duration overall was {:.2f} seconds"\
.format(rides['Duration'].____()))
# Median of joyrides
print("The median duration for joyrides was {:.2f} seconds"\
.format(rides[____]['Duration'].____()))