February 2019
Beginner to intermediate
308 pages
7h 42m
English
Next, let's investigate how the number of rides varies by day and hour.
Recall that the raw data contains a single pickup_datetime column that contains the pickup date and time in datetime format. First, let's separate the pickup year, month, day, day of week, and hour from the original pickup_datetime column into different columns:
df['year'] = df['pickup_datetime'].dt.yeardf['month'] = df['pickup_datetime'].dt.monthdf['day'] = df['pickup_datetime'].dt.daydf['day_of_week'] = df['pickup_datetime'].dt.dayofweekdf['hour'] = df['pickup_datetime'].dt.hour
Since we have previously used the parse_dates parameter when we imported the data into pandas, we can easily identify and separate the year, month, day and hour components ...