Analyzing CitiBike Data: EDA
By: Sujan Shirol
Tags: Seaborn, Python Matplotlib, Visualization, Data Analytics, Data Science

Let’s get some more information on the data.

df.info()

#sum of missing values in each column

df.isna().sum()

We have whooping 5,77,703 rows to crunch and 15 columns. Also, quite a bit of missing values. Let’s deal with missing values first.

Handling missing values

Let’s first see the percentage of missing values which will help us decide whether to drop them or no.

We can not afford to drop the missing valued rows of ‘birth year’. Hence, drop the entire column ‘birth year’ and drop missing valued rows of ‘end station id’,‘ end station name’,‘ end station latitude’, and ‘end station longitude’. Fortunately, all the missing values in these four rows (end station id, end station name, end station latitude, and end station longitude) are on the exact same row, so dropping NaN rows from all four rows will still result in only 3% data loss.

Let’s see what gender talks about our data

We can see more male riders than females in New York City but due to a large number of unknown gender, we cannot get to any concrete conclusion. Filling unknown gender values is possible but we are not going to do it considering riders did not choose to disclose their gender.

Subscribers vs Customers

Subscribers are the users who bought the annual pass and customers are the once who bought either a 24-hour pass or a 3-day pass. Let’s see what the riders choose the most.

We can see there is more number of yearly subscribers than 1-3day customers. But the difference is not much, the company has to focus on converting customers to subscribers with some offers or sale.

How many hours do rides use the bike typically

We have a column called ‘timeduration’ which talks about the duration each trip covered which is in seconds. Firstly, we will convert it to minutes, then create bins to group the trips into 0–30min, 30–60min, 60–120min, 120min, and above ride time. Then, let’s plot a graph to see how many hours do rides ride the bike typically.

There are a large number of riders who ride for less than half an hour per trip and most less than 1 hour.

Same start and end location VS different start and end location

We see in the data there are some trips that start and end at the same location. Let’s see how many.

Riding pattern of the month

This part is where I have spent a lot of time and effort. The below graph talks a lot. Technically there is a lot of coding. Before looking at the code I will give an overview of what we are doing here. Basically, we are plotting a time series graph to see the trend of the number of rides taken per day and the trend of the total number of duration the bikes were in use per day. Let’s look at the code first then I will break it down for you.

You might have understood the basic idea by reading the comments but let me explain the process step-by-step:

The date-time is in the string, we will convert it into DateTime object. Grouping the data by days of the month and counting the number of occurrences to plot rides per day. We have only one row with the information for the month of July. This is an outlier, drop it. Repeat steps 2 and 3 but the only difference this time is we sum the data instead of counting to get the total time duration of the trips per day. Plot both the data on a single graph using the twin axis method.

I have used a lot of tweaking methods on matplotlib, make sure to go through each of them. If any doubts drop a comment on the Kaggle notebook for which the link will be dropped at the end of this article.