52

weeks

Week 44 - Ecobici bike rides

This week I visualized my Ecobici (city bike rental) bike rides over the last few months.

Tool I used:

  • Ecobici - Mexico City’s bike share system

  • Python - to query graphQL, process data, and make a few charts

Context

Mexico City has a bike share system similar to many other cities I’ve been to; theirs is called Ecobici, launched in 2010 and now has over 700 stations around the city. I ride it several days a week to cover my short commutes. I’ve been riding it for 6 months with >100 rides, enough data to make a few charts on my usage.

Process

Firstly, I needed to download my ride data from the Ecobici website. Armed with the confidence from last week’s scraping, I was ready to tackle this (much easier) task.

After logging in to the ecobici web portal and inspecting the page, I see they are using GraphQL to store and serve the ride data.

This makes it super easy to query all the data I need from their endpoint. No scraping required!

I cobbled together a request script in Python using an auth cookie, my user ID, and a query string, and downloaded all my rides + details of start/end time and station ID/name.

Conveniently, they also have a map showing all the stations. Inspecting this page gave me perfectly formatted JSON with latitude/longitude for each station:

I matched these with my rides to complete my basic dataset. Then I made a few charts to explore.

Firstly, where have I been riding?

Represented are a few key spots the I go regularly (near my house, the coworking space, the climbing gym) and then a longer tail of small adventures.

How about when?

Earlier in the year I was riding early to go to Spanish lessons. There was a gap in August/September where I wasn’t riding much, and more recently I’ve been staying out and riding home after climbing in the evenings.

I have the start and end locations as well as the duration of the bike trip, so I can calculate my average speed.

Looks like I typically bike faster in the mornings (usually because I have to be somewhere on time, and perhaps the morning rush hour traffic encourages me to speed up), especially if I’m biking around 10am. In the evenings I tend to be more relaxed and/or tired, and I go slower.

There seems to be a minor trend of me slowing down as the week progresses, except on Saturday I’m full of energy again and go significantly faster.

Learnings

  • GraphQL is easy to query

  • I always wondered if I was actually biking faster at certain times of the day, seems like that’s true

Next steps

  • Do the same thing for our car, Uber, and walking travel