Bike sharing has become more popular in recent days. It not only serves as a new way to transit, but also a hobby for many people who prefer a more convenient way to ride.
The dataset includes the data of stations, trips, and weather in 3 cities: Montreal, Toronto, and Washington DC.
Our goal is to improve one data analysis of bike sharing on kaggle and to explore more details by adding two hypotheses in this project to make it more comprehensive.
Use the package manager pip to install some modules.
pip install scipy
pip install seaborn
pip install numpy
pip install pandas
pip install matplotlib
pip install haversine
Import scipy, seaborn, numpy, pandas, matplotlib, datetime, haversine.
from scipy import stats
from haversine import haversine
import seaborn as sns
import numpy as np
import pandas as pd
import datetime
import matplotlib.pyplot as plt
Due to the limitation of uploading files on Git, please download the files as below to run the code.
- Bike Sharing - Big Data Systems development & implementation
https://www.kaggle.com/v1teka/bike-sharing-big-data-systems-dev-impl/notebook
- Capital Bikeshare trip history data (Please use the files of 2020 April, 2020 Maym and 2020 June)
https://s3.amazonaws.com/capitalbikeshare-data/index.html
- COVID-19 in USA
https://www.kaggle.com/sudalairajkumar/covid19-in-usa
Trip Dataframe
Station Dataframe
Weather Dataframe
Weather conditions:
prectot: Precipitation (mm day-1)
qv2m : Specific Humidity at 2 Meters (g/kg)
rh2m: Relative Humidity at 2 Meters (%)
ps: Surface Pressure (kPa)
t2m_range: Temperature Range at 2 Meters (C)
ts: Earth Skin Temperature (C)
t2mdew: Dew/Frost Point at 2 Meters (C)
t2mwet: Wet Bulb Temperature at 2 Meters (C)
t2m_max: Maximum Temperature at 2 Meters (C)
t2m_min: Minimum Temperature at 2 Meters (C)
t2m: Temperature at 2 Meters (C)
ws50m_range: Wind Speed Range at 50 Meters (m/s)
ws10m_range: Wind Speed Range at 10 Meters (m/s)
ws50m_min: Minimum Wind Speed at 50 Meters (m/s)
ws10m_min: Minimum Wind Speed at 10 Meters (m/s)
ws50m_max: Maximum Wind Speed at 50 Meters (m/s)
ws10m_max: Maximum Wind Speed at 10 Meters (m/s)
ws50m: Wind Speed at 50 Meters (m/s)
ws10m: Wind Speed at 10 Meters (m/s)\
Hypothesis #1 - Total daily trips duration depends on weather conditions (Take Montreal for example)
Here are some scatter plots, they show us the correlation between weather conditions and total daily trips duration. I used the for loop to draw the scatter plot and set titles for each factor.
If we want to go through the correlation between each factor and total daily trips duration, we can use some statistical methods. We chose the Pearson correlation coefficient which is a measure of linear correlation between two sets of data. We got two numbers from the method. The first number is Pearson's r, which means a numerical summary of the strength of the linear association between the variables, and the second number is the probability that the true value of r is zero. We can find out that there is a linear relationship between the maximum temperature and total daily trips duration. By contrast, the maximum wind speed at 50 meters and total daily trips duration have the largest negative correlation.
Here is a correlation matrix and every correlation matrix is symmetrical.
This is a heat map. We can clearly spot linear relationships between variables through the heat map.
We aimed to verify if club members ride longer in a trip.
You can see that in Montreal, casual riders have a longer duration in a trip compared to the member riders. The difference is about an average of 400 to 600 seconds. Six minutes to 10 minutes.
For the Toronto area, this visualization couldn’t provide much information because the data of the member riders in the dataset is incomplete, so we couldn’t explore more for this area based on this hypothesis.
As for the Washington region, the casual riders also ride longer than the member riders in a trip. Moreover, compared to the result of Montreal, the duration difference between member riders and casual riders is bigger. It’s about an average of 8 minutes to 20 minutes.
Calculate the percentage of members riding bikes.
In conclusion about Montreal, we found out that there are some missing data in the dataset. However, if there is sufficient data for the whole year, then you can find out compared to casual riders, member riders have a higher possibility to take bikes in 2014.
In Toronto, the dataset only records casual riders. So, in this dataset, we can only find out when the casual riders ride bikes. We cannot come to the conclusion of this hypothesis due to the fact that the dataset did not provide sufficient data for us to explore.
In Washington, you can see that the proportion of casual riders is quite low just like in Montreal. It fits the hypothesis compared to casual riders, member riders have a higher possibility to take bikes.
Hypothesis #4 - During April to June in 2020, members tend to ride a longer distance than casual riders on a trip in Washington.
In April, members tend to ride a longer distance than casual riders.
In May, members tend to ride a little longer distance than casual riders.
In June, casual riders tend to ride a longer distance than members.
Hypothesis #5 - During April to June in 2020, as the number of confirmed cases for coronavirus increases, the daily average distance of trips would decrease in Washington.
The relationship between daily distance and confired cases in April 2020.
The relationship between daily distance and confired cases in May 2020.
The relationship between daily distance and confired cases in June 2020.