Cyclistic Bike Share Analysis
Cleaned and merged five quarters of messy trip data with R, then used it to find how annual members and casual riders differ and what to do about it.
- R
- R Studio
- dplyr
- ggplot2
- CSV
- Kaggle
Overview
This was the capstone for the Google Data Analytics Professional Certificate. I worked with public trip data from Chicago’s Divvy bike share, framed as a fictional company called Cyclistic. The task: how do annual members and casual riders use bikes differently? The marketing director wanted the answer to design a campaign that converts casual riders into members.
The full notebook, with every cleaning and analysis step, is on Kaggle.
Why this is here
I included this one because most of it was troubleshooting. Five files that should have matched didn’t, and I had to work out why before I could fix anything. That’s the habit I’d like to bring to support work.
The problem: five files that didn’t match
The data came as five quarterly CSV files, 2019 Q1 through 2020 Q1, and they didn’t agree with each other:
- 2019 Q2 used different column names than the other 2019 files.
- 2020 Q1 had a different structure altogether. It was missing
gender,birthyearandtripduration, had extra columns such as coordinates and bike type, and stored the trip ID as text instead of an integer.
I renamed and aligned columns, added the missing ones as NA, recalculated trip duration from the start and end timestamps, recoded the user types so the files matched, and combined everything with bind_rows().
Validating the data
Before analyzing anything I checked each column. Trip IDs were unique, and station IDs had no missing values and sensible ranges. The timestamps turned up a real error: 130 trips ended before they started. I couldn’t verify the rest of those rows, so I dropped them.
# Find trips whose end time is earlier than the start time
idx <- which(bike_trip_data$end_time < bike_trip_data$start_time)
# Drop them
bike_trip_data <- bike_trip_data[-c(idx), ]
The recalculated durations also contained outliers: one trip lasted 123 days, and others lasted seconds. Those looked like system errors or lost bikes, so I limited the analysis to trips between one minute and 48 hours, then to a day or less after checking how many long trips each group had.
Findings
- Annual members took 78.2% of trips. Casual riders took 21.8%.
- Both groups ride more in spring and summer, but casual riders almost disappear from November through February.
- Casual riders ride mostly on weekends. Members ride mostly on weekdays, which points to commuting.
- Casual trips are much longer: about 39 minutes on average, against about 13 for members.
- Casual riders favor stations in tourist areas such as the South Loop. Members favor the West Loop business district.
Recommendations
- Run the campaign in spring and summer, when casual riders are active.
- Spend more on weekends, when casual ridership peaks.
- Target the stations casual riders actually use, because the busiest stations are mostly used by existing members.
- Gather more information on who casual riders are, for example with a survey.
What I took from it
- Look at why things disagree before changing anything.
- Write down each decision so someone else can follow along.
- Check the data for mistakes instead of assuming it’s right.
- Explain technical results to people who just want the answer.