<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="assets/xml/rss.xsl" media="all"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Mike Jarrett</title><link>https://notes.mikejarrett.ca/</link><description>Mike Jarrett's Blog</description><atom:link href="https://notes.mikejarrett.ca/rss.xml" rel="self" type="application/rss+xml"></atom:link><language>en</language><copyright>Contents © 2025 &lt;a href="mailto:mike@mikejarrett.ca"&gt;Mike Jarrett&lt;/a&gt; </copyright><lastBuildDate>Fri, 29 Aug 2025 20:46:31 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Mobi Station Networks</title><link>https://notes.mikejarrett.ca/mobi-station-networks/</link><dc:creator>Mike Jarrett</dc:creator><description>&lt;div class="cell border-box-sizing text_cell rendered"&gt;&lt;div class="prompt input_prompt"&gt;
&lt;/div&gt;&lt;div class="inner_cell"&gt;
&lt;div class="text_cell_render border-box-sizing rendered_html"&gt;
&lt;p&gt;I've started wondering if there are any network effects in Mobi trip data. I don't know much about network analysis, but luckily there are python packages to do the work for me: &lt;a href="https://networkx.github.io/"&gt;NetworkX&lt;/a&gt; provides general network analysis tools and basic plotting, and &lt;a href="https://python-louvain.readthedocs.io/en/latest/api.html"&gt;Community&lt;/a&gt; provides tools for determining clusters in a network. In this post, I'll use these tools to investigate how stations cluster together based on the frequency of trips between pairs of stations&lt;/p&gt;
&lt;p&gt;&lt;a href="https://notes.mikejarrett.ca/mobi-station-networks/"&gt;Read more…&lt;/a&gt; (40 min remaining to read)&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description><guid>https://notes.mikejarrett.ca/mobi-station-networks/</guid><pubDate>Mon, 17 Feb 2020 19:43:55 GMT</pubDate></item><item><title>Tracking bikeshare use using GBFS feeds</title><link>https://notes.mikejarrett.ca/tracking-bikeshare-use-using-gbfs-feeds/</link><dc:creator>Mike Jarrett</dc:creator><description>&lt;figure&gt;&lt;img src="https://notes.mikejarrett.ca/images/logo.png"&gt;&lt;/figure&gt; &lt;div class="cell border-box-sizing text_cell rendered"&gt;&lt;div class="prompt input_prompt"&gt;
&lt;/div&gt;&lt;div class="inner_cell"&gt;
&lt;div class="text_cell_render border-box-sizing rendered_html"&gt;
&lt;p&gt;The &lt;a href="https://github.com/NABSA/gbfs"&gt;General Bikeshare Feed Specification (GBFS)&lt;/a&gt; is a popular standard for publishing live data about bikeshare systems used by systems &lt;a href="https://github.com/NABSA/gbfs/blob/master/systems.csv"&gt;around the globe&lt;/a&gt;. Its stated purpose is to allow 3rd party applications to interface with the live data and allow municipalities to monitor compliance with local regulations. For my purpose, it also allows me to monitor system usage in real time. Here I'll go through the steps I use to track bikeshare usage in real time using GBFS feeds. I currently publish live tracking of Vancouver bikeshare systems at &lt;a href="http://twitter.com/vanbikesharebot"&gt;@VanBikeShareBot&lt;/a&gt; and will soon be adding tracking of Toronto, Hamilton and Montreal systems.&lt;/p&gt;
&lt;p&gt;I've bundled the tools I use for GBFS monitoring into a python package that can be &lt;a href="https://github.com/mjarrett/bikedata"&gt;found on Github&lt;/a&gt;. The Bikedata package is not a full-service GBFS client -- for that, you might prefer &lt;a href="https://pypi.org/project/gbfs-client/"&gt;GBFS-client&lt;/a&gt;. Bikedata provides minimal functionality for querying GBFS feeds and returning Pandas dataframes, and implements some helper functions for persistent monitoring of bikeshare systems.&lt;/p&gt;
&lt;h3 id="The-GBFS-spec"&gt;The GBFS spec&lt;a class="anchor-link" href="https://notes.mikejarrett.ca/tracking-bikeshare-use-using-gbfs-feeds/#The-GBFS-spec"&gt;¶&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;I won't go into detail about the GBFS spec, more information can be found on the project's &lt;a href="https://github.com/NABSA/gbfs"&gt;Github page&lt;/a&gt;. Suffice to say that a GBFS complient system offers several distinct JSON endpoints that provide information about the system. For example, Mobi Bikes in Vancouver provides:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://vancouver-gbfs.smoove.pro/gbfs/gbfs.json"&gt;https://vancouver-gbfs.smoove.pro/gbfs/gbfs.json&lt;/a&gt;: A list of available feeds&lt;/li&gt;
&lt;li&gt;&lt;a href="https://vancouver-gbfs.smoove.pro/gbfs/en/system_information.json"&gt;https://vancouver-gbfs.smoove.pro/gbfs/en/system_information.json&lt;/a&gt;: General system information&lt;/li&gt;
&lt;li&gt;&lt;a href="https://vancouver-gbfs.smoove.pro/gbfs/en/station_information.json"&gt;https://vancouver-gbfs.smoove.pro/gbfs/en/station_information.json&lt;/a&gt;: Details about stations (short and long names, location, coordinates)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://vancouver-gbfs.smoove.pro/gbfs/en/station_status.json"&gt;https://vancouver-gbfs.smoove.pro/gbfs/en/station_status.json&lt;/a&gt;: Live status of stations (bikes available, free docks)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Mobi doesn't have free floating bikes, but systems that do also have a &lt;code&gt;free_bikes.json&lt;/code&gt; feed providing the location of available free floating bikes.&lt;/p&gt;
&lt;h3 id="Tracking-station-based-systems"&gt;Tracking station-based systems&lt;a class="anchor-link" href="https://notes.mikejarrett.ca/tracking-bikeshare-use-using-gbfs-feeds/#Tracking-station-based-systems"&gt;¶&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Many bikeshare systems, especially those in dense city centres, only allow trips to begin and end at physical stations. To monitor these systems, I periodically query the &lt;code&gt;station_status.json&lt;/code&gt; and record the number of bikes at each station. If the number of available bikes decreases by N, I count that as N departures from the station. If it increases by M, I count that as M bikes returned.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://notes.mikejarrett.ca/tracking-bikeshare-use-using-gbfs-feeds/"&gt;Read more…&lt;/a&gt; (37 min remaining to read)&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description><category>bikes</category><category>mobi</category><guid>https://notes.mikejarrett.ca/tracking-bikeshare-use-using-gbfs-feeds/</guid><pubDate>Mon, 20 Jan 2020 01:12:56 GMT</pubDate></item><item><title>Mapping Vancouver's Buses</title><link>https://notes.mikejarrett.ca/mapping-vancouvers-buses/</link><dc:creator>Mike Jarrett</dc:creator><description>&lt;div class="cell border-box-sizing text_cell rendered"&gt;&lt;div class="prompt input_prompt"&gt;
&lt;/div&gt;&lt;div class="inner_cell"&gt;
&lt;div class="text_cell_render border-box-sizing rendered_html"&gt;
&lt;p&gt;I came across &lt;a href="https://twitter.com/realtimebus"&gt;@realtimebus&lt;/a&gt; the other day and immediately wanted to recreate it for Vancouver. Luckily &lt;a href="https://developer.translink.ca/"&gt;Translink has a realtime bus API&lt;/a&gt; that I could pull from and making an animated gif is pretty straightforward in Python. And since I already have some experience making twitter bots with &lt;a href="https://twitter.com/VanBikeShareBot"&gt;@VanBikeShareBot&lt;/a&gt; I felt like I didn't really have a choice.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://notes.mikejarrett.ca/mapping-vancouvers-buses/"&gt;Read more…&lt;/a&gt; (19 min remaining to read)&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description><guid>https://notes.mikejarrett.ca/mapping-vancouvers-buses/</guid><pubDate>Sun, 17 Feb 2019 05:26:54 GMT</pubDate></item><item><title>Optimizing your Nikola blog for Jupyter notebooks</title><link>https://notes.mikejarrett.ca/optimizing-your-nikola-blog-for-jupyter-notebooks/</link><dc:creator>Mike Jarrett</dc:creator><description>&lt;div class="cell border-box-sizing text_cell rendered"&gt;&lt;div class="prompt input_prompt"&gt;
&lt;/div&gt;&lt;div class="inner_cell"&gt;
&lt;div class="text_cell_render border-box-sizing rendered_html"&gt;
&lt;p&gt;You've installed &lt;a href="https://getnikola.com"&gt;Nikola&lt;/a&gt;. You've also followed &lt;a href="https://mglerner.github.io/posts/switching-to-nikloa-for-jupyter-notebooks-and-a-static-site.html"&gt;some instructions on how to use Jupyter notebooks as posts&lt;/a&gt;. Everything works! But after you make your first Jupyter post, the results are... uninspiring. The input prompts are ugly. If you've written a post designed primarily for the content, not the code, there's no was to turn off showing the code cells. This post will describe how I -- someone with almost no experience with javascript, CSS, etc -- made my blog more functional to work with Jupyter notebooks.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://notes.mikejarrett.ca/optimizing-your-nikola-blog-for-jupyter-notebooks/"&gt;Read more…&lt;/a&gt; (5 min remaining to read)&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description><category>jupyter</category><category>nikola</category><category>theme</category><guid>https://notes.mikejarrett.ca/optimizing-your-nikola-blog-for-jupyter-notebooks/</guid><pubDate>Tue, 15 Jan 2019 00:27:18 GMT</pubDate></item><item><title>Connecting neighbourhoods</title><link>https://notes.mikejarrett.ca/connecting-neighbourhoods/</link><dc:creator>Mike Jarrett</dc:creator><description>&lt;div class="cell border-box-sizing text_cell rendered"&gt;&lt;div class="prompt input_prompt"&gt;
&lt;/div&gt;&lt;div class="inner_cell"&gt;
&lt;div class="text_cell_render border-box-sizing rendered_html"&gt;
&lt;p&gt;I've been working on how best to look at connections between the various Mobi bikeshare stations throughout Vancouver. One thing the quickly became obvious was that some visualizations are much too noisy with all stations, but work nicely when I group stations into neighbourhoods. Luckily the city &lt;a href="https://data.vancouver.ca/datacatalogue/index.htm"&gt;geometry files of the various neighourhoods available in their open data collection&lt;/a&gt;, so I was able to use those to group the stations according to the city's official definitions. See the distributions of stations below.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://notes.mikejarrett.ca/connecting-neighbourhoods/"&gt;Read more…&lt;/a&gt; (130 min remaining to read)&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description><guid>https://notes.mikejarrett.ca/connecting-neighbourhoods/</guid><pubDate>Sun, 13 Jan 2019 23:08:50 GMT</pubDate></item><item><title>How Vancouver Uses Mobi Bikes</title><link>https://notes.mikejarrett.ca/how-vancouver-uses-mobi-bikes/</link><dc:creator>Mike Jarrett</dc:creator><description>&lt;div class="cell border-box-sizing text_cell rendered"&gt;&lt;div class="prompt input_prompt"&gt;
&lt;/div&gt;&lt;div class="inner_cell"&gt;
&lt;div class="text_cell_render border-box-sizing rendered_html"&gt;
&lt;p&gt;Vancouver's Mobi bikeshare system has been up and running for over 2 years now, and with two full summers of activity it's time to take a look at how exactly Vancouverites are using their bikeshare system.&lt;/p&gt;
&lt;p&gt;For over a year, I've been collecting real-time data about Mobi bike trips by monitoring public information about the number of bikes at each station and inferring trip activity based on changes to the number of bikes at each station. This has led to some fun uses: I have live figures updating constantly on &lt;a href="https://notes.mikejarrett.ca/how-vancouver-uses-mobi-bikes/data.mikejarrett.ca/mobi"&gt;my website&lt;/a&gt;, a twitter bot tweets out daily stats at &lt;a href="https://notes.mikejarrett.ca/how-vancouver-uses-mobi-bikes/twitter.com/VanBikeShareBot"&gt;@VanBikeShareBot&lt;/a&gt;, and a few &lt;a href="http://notes.mikejarrett.ca/categories/mobi/"&gt;blog posts&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;As handy as those live trip estimates are, they're very much estimates and only give us information about how often certain stations are used. Luckily, Mobi has started publishing open &lt;a href="https://www.mobibikes.ca/en/system-data"&gt;system data&lt;/a&gt;. This data set gives us a registry of every Mobi bikeshare trip since the beginning of 2017, current to the end of 2018 as of this writing. With this we have access to trip start and endpoints, trip duration and distance, membership type and more. In this post, I'll summarize some of the things I've learned after spending some time looking into this data.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://notes.mikejarrett.ca/how-vancouver-uses-mobi-bikes/"&gt;Read more…&lt;/a&gt; (214 min remaining to read)&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description><category>bikes</category><category>datavis</category><category>mobi</category><guid>https://notes.mikejarrett.ca/how-vancouver-uses-mobi-bikes/</guid><pubDate>Mon, 07 Jan 2019 02:27:37 GMT</pubDate></item><item><title>Storing metadata in Pandas DataFrames</title><link>https://notes.mikejarrett.ca/storing-metadata-in-pandas-dataframes/</link><dc:creator>Mike Jarrett</dc:creator><description>&lt;div class="cell border-box-sizing text_cell rendered"&gt;&lt;div class="prompt input_prompt"&gt;
&lt;/div&gt;&lt;div class="inner_cell"&gt;
&lt;div class="text_cell_render border-box-sizing rendered_html"&gt;
&lt;p&gt;I came across a problem recently where I wanted to store metadata about each column in a pandas DataFrame. This could be done easily enough with a simple dictionary where each column name is a key, but I was hoping for something that would propogate with a DataFrame as it's sliced, copied, expanded, etc, without having to explicitely keep track of the metadata in my scripts.&lt;/p&gt;
&lt;p&gt;My solution is to use the pandas MultiIndex. In this post I'll discuss the pros and cons of this approach, show some examples, a show how I've subclassed the pandas DataFrame to make this approach easier.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://notes.mikejarrett.ca/storing-metadata-in-pandas-dataframes/"&gt;Read more…&lt;/a&gt; (6 min remaining to read)&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description><guid>https://notes.mikejarrett.ca/storing-metadata-in-pandas-dataframes/</guid><pubDate>Fri, 06 Apr 2018 04:12:42 GMT</pubDate></item><item><title>Mountain View Cemetary Open Data</title><link>https://notes.mikejarrett.ca/mountain-view-cemetary-open-data/</link><dc:creator>Mike Jarrett</dc:creator><description>&lt;figure&gt;&lt;img src="https://data.mikejarrett.ca/images/logo.png"&gt;&lt;/figure&gt; &lt;div class="cell border-box-sizing text_cell rendered"&gt;&lt;div class="prompt input_prompt"&gt;
&lt;/div&gt;&lt;div class="inner_cell"&gt;
&lt;div class="text_cell_render border-box-sizing rendered_html"&gt;
&lt;h2 id="Mountain-View-Cemetary-Open-Data"&gt;Mountain View Cemetary Open Data&lt;a class="anchor-link" href="https://notes.mikejarrett.ca/mountain-view-cemetary-open-data/#Mountain-View-Cemetary-Open-Data"&gt;¶&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;One of my goals this year is to turn everything interesting I learn into a blog post. I've been using &lt;a href="http://data.vancouver.ca/datacatalogue/"&gt;Vancouver's open data&lt;/a&gt; to find datasets to play around with, and the site includes some &lt;a href="http://data.vancouver.ca/datacatalogue/mountainViewCemeteryBurialIndex.htm"&gt;data about people interred at Mountain View Cemetary&lt;/a&gt;. A little morbid for a data vis exercise, but I'm doing it anyways.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://notes.mikejarrett.ca/mountain-view-cemetary-open-data/"&gt;Read more…&lt;/a&gt; (37 min remaining to read)&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description><guid>https://notes.mikejarrett.ca/mountain-view-cemetary-open-data/</guid><pubDate>Fri, 02 Mar 2018 23:29:02 GMT</pubDate></item><item><title>Mapping Google's Location History in Python</title><link>https://notes.mikejarrett.ca/mapping-googles-location-history-in-python/</link><dc:creator>Mike Jarrett</dc:creator><description>&lt;div class="cell border-box-sizing text_cell rendered"&gt;&lt;div class="prompt input_prompt"&gt;
&lt;/div&gt;&lt;div class="inner_cell"&gt;
&lt;div class="text_cell_render border-box-sizing rendered_html"&gt;
&lt;p&gt;If you have an Android phone, Google is tracking your location. If you have "Location History" turned on in your settings, Google is &lt;em&gt;really&lt;/em&gt; tracking your location. If you have this setting turned off, Google will still record your location when an app that has proper permission (like Google Maps or Strava) requests your location. This is creepy and probably bad from a privacy standpoint, but it's cool and fun from a data and visualisation standpoint. In the interest of blog content, I've let google track my location since I got my new phone ~1.5 years ago and it's now time to look at the data.&lt;/p&gt;
&lt;p&gt;Google offers ways to look at your location history through their apps, but it's more fun to do it myself. Through myaccount.google.com, you can create an archive of your personal information being stored by Google. You can pick which services you're interested in, but for now I'm just looking for my location history data. It takes some time for Google to create the archive and make it available for download.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://notes.mikejarrett.ca/mapping-googles-location-history-in-python/"&gt;Read more…&lt;/a&gt; (8 min remaining to read)&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description><guid>https://notes.mikejarrett.ca/mapping-googles-location-history-in-python/</guid><pubDate>Sat, 06 Jan 2018 03:45:54 GMT</pubDate></item><item><title>What really affects bikeshare use in Vancouver?</title><link>https://notes.mikejarrett.ca/what-really-affects-bikeshare-use-in-vancouver/</link><dc:creator>Mike Jarrett</dc:creator><description>&lt;p&gt;City staff recently reported to Council about the status of the Mobi bikeshare system. You can see the slideshow for yourself &lt;a href="http://council.vancouver.ca/20171115/documents/cfsc3presentation.pdf"&gt;here&lt;/a&gt;. Results generally look positive for the future of bikeshare in Vancouver, but a comment one slide stuck out for me: "Temperature influences ridership more than precipitation".

Is this really true? In my experience, biking on a cool, dry day is much more enjoyable than biking on a warm rainy day. There was no clue in the council report on how they came to this conclusion, but I suspect they used the eyeball test. But the cooler months in Vancouver are also the rainy months, so a more careful analysis is needed. I'd recently seen an example in Jake Vanderplas' &lt;a href="https://github.com/jakevdp/PythonDataScienceHandbook"&gt;Python Data Science Handbook&lt;/a&gt; that looked at the factors influencing bike ridership in Seattle, so I decided to do a similar thing for Vancouver.

&lt;!--more--&gt;

I've described at bit more about how I collected the Mobi trip data in a &lt;a href="http://mikejarrett.ca/blog/2017/10/machine-learning-with-vancouver-bike-share-data/"&gt;previous post&lt;/a&gt;. While the data is unofficial and has some clear sources of error, it should be reliable to look at usage trends. For weather data, I wrote a small scraper to grab historical Vancouver weather from weather.gc.ca. All the code I used for this post is available on &lt;a href="https://github.com/mjarrett/mobi"&gt;my github page&lt;/a&gt;.

First, let's take a zoomed out look at bike usage from late April to early November 2017. Rainfall and daily highs are plotted on the same scale, in degrees Celcius and millimeters of rain. Weekends are highlighted by grey bars. The first thing we see is the obvious broad trend across the seasons, matching up with the temperature trend. This is probably what city staff noticed. Next, we see that on days with sharp drop-offs from the broader trend, there's almost always some rainfall. So far so good!

&lt;img class="alignnone size-full wp-image-255" src="https://notes.mikejarrett.ca/images/weather_plot_2017-04-20-2017-11-03.png" alt="" width="640" height="480"&gt;

 

(Days with missing data are days I had computer downtime before I moved my scraper to a cloud server.)

A few things to note. Weather data is per day, and for just one Vancouver weather station. There are certainly days where it pours overnight and the day is clear, or it rains more in one part of the city than another. That said, let's take a closer look at a few weeks.

&lt;img class="alignnone size-full wp-image-253" src="https://notes.mikejarrett.ca/images/weather_plot_2017-06-02-2017-06-21.png" alt="" width="640" height="480"&gt;

Here's two consecutive weekends where there was substantial rain on Sunday but none on Saturday. The drop-off is clear on both weekends. But later in the second week, there is a day with much less rainfall that has almost the same drop-off in number of trips.

&lt;img class="alignnone size-full wp-image-254" src="https://notes.mikejarrett.ca/images/weather_plot_2017-09-01-2017-09-21.png" alt="" width="640" height="480"&gt;

Here's another three week stretch. Again, days with rain clearly show reduced Mobi usage. But usage also follows the temperature line! How much of the variation in bike usage is due to temperature, and how much is due to rain?

First let's look at temperature and rainfall separately.

&lt;img class="alignnone size-full wp-image-269" src="https://notes.mikejarrett.ca/images/trips_vs_temp.png" alt="" width="640" height="480"&gt;

The relationship between temperature and bike share trips is strong and exactly what you'd expect. More people ride on warm days! I've coloured the data by rainfall to see if there's any interesting outliers, but the rainy days are all well within the trend. We had pretty great weather all summer this year, so no examples of really rainy days with warm temperatures.

&lt;img class="alignnone size-full wp-image-235" style="font-size: 1rem;" src="https://notes.mikejarrett.ca/images/trips_vs_rainfall.png" alt="" width="640" height="480"&gt;

Rainfall also shows a clear relationship with daily trips. But it's not linear like temperature. There's a band of zero rain days that correlate with temperature, then a linear segment as ridership falls off with increased rainfall, then ridership hits a baseline below which it doesn't decrease. Apparently regardless of the amount of rain there's something like 600-800 users who will take out a bike no matter what. Cool!

So, we need to make a model that incorporates both temperature and rainfall to try to separate their effects. But to be as accurate as possible, we should include any other prominent factors. I showed in a earlier post that over the course of a day, weekdays and weekends show different ridership patters. But it turns out there's no obvious difference in the total number of trips.

&lt;img class="alignnone size-full wp-image-241" style="font-size: 1rem;" src="https://notes.mikejarrett.ca/images/weekdays_vs_weekends_boxplot.png" alt="" width="640" height="480"&gt;

If we're going to think about weekday vs weekend, let's just include each day of the week as a separate factor. Stat holiday vs not holiday should also be included. Since there's such a dramatic difference between days with any rain and days with no rain, let's include "dry" days as a factor. The last factor I'll include is hours of daylight -- when it gets dark before 5pm, it's hard to say whether it's the temperature or the darkness that has more on an effect someone's decision to ride a Mobi.

&lt;code&gt;Trips ~ Temperature + Rainfall + Dry + Holiday + Daylight + Monday + Tuesday + Wednesday + Thursday + Friday + Saturday + Sunday&lt;/code&gt;

To fit the model, I'll use the OLS (ordinary least squares) class from the statsmodels Python package.
&lt;/p&gt;&lt;pre&gt;                            OLS Regression Results                            
==============================================================================
Dep. Variable:                  Trips       R-squared:                       0.812
Model:                            OLS          Adj. R-squared:                  0.801
Method:                 Least Squares  F-statistic:                     69.65
Date:                Tue, 21 Nov 2017   Prob (F-statistic):           2.49e-58
Time:                        13:57:32           Log-Likelihood:                -1376.9
No. Observations:                 189    AIC:                             2778.
Df Residuals:                     177          BIC:                             2817.
Df Model:                          11                                         
Covariance Type:            nonrobust                                         
================================================================================
                                    coef    std err          t      P&amp;gt;|t|      [0.025      0.975]
--------------------------------------------------------------------------------
Max Temp           117.3302      8.079     14.522      0.000     101.386     133.274
Total Rainmm   -29.8730      6.715     -4.449      0.000     -43.124     -16.622
Mon                     -523.1535    209.4     -2.498      0.013    -936.401    -109.906
Tue                      -523.9437    206.4     -2.537      0.012    -931.439    -116.448
Wed                    -497.6093    209.4     -2.376      0.019    -910.967     -84.252
Thu                     -429.2738    213.2     -2.013      0.046    -850.082      -8.465
Fri                       -368.8536    207.5     -1.777      0.077    -778.440      40.733
Sat                       -487.4666    206.5     -2.360      0.019    -895.072     -79.861
Sun                      -755.6349    207.6     -3.640      0.000   -1165.364    -345.906
Dry                      362.8911     75.665      4.796      0.000     213.569     512.214
Holiday               -277.1649    181.6     -1.526      0.129    -635.701      81.371
daylight_hrs       37.2471       15.672      2.377      0.019       6.319      68.175
==============================================================================
Omnibus:                        9.879   Durbin-Watson:                 1.087
Prob(Omnibus):             0.007   Jarque-Bera (JB):               20.264
Skew:                                0.116   Prob(JB):                             3.98e-05
Kurtosis:                          4.587   Cond. No.                            472.
==============================================================================


&lt;/pre&gt;
We can take a few things away from this table. The adjusted R&lt;sup&gt;2 &lt;/sup&gt;value is 0.801 which means our model explains about 80% of the variance in the data. Pretty good! We can also say that, all other things being equal, there will be
&lt;ul&gt;
    &lt;li&gt;117 more trips for each increase of one degree Celcius&lt;/li&gt;
    &lt;li&gt;30 fewer trips for each additional of 1 mm of rain&lt;/li&gt;
    &lt;li&gt;277 fewer trips on holidays versus equivalent non-holidays&lt;/li&gt;
    &lt;li&gt;37 more trips for each additional hour of daylight&lt;/li&gt;
&lt;/ul&gt;
The coefficients associated with the days of the week can be interpreted as the intercept for each day of the week, in other words the number of trips expected on that day if all other factors are zero. This is obviously nonsense, since we can't have fewer than zero trips. But the daily high temperature for the dates I have data for are all well above zero, so the model doesn't have any data for temperatures near zero. More on this later.

Given our model, we can plot the expected number of trips for each day on top of the measured number of trip.

&lt;img class="alignnone size-full wp-image-248" src="https://notes.mikejarrett.ca/images/trip_vs_predicted_full_model.png" alt="" width="640" height="480"&gt;

The model nails the macroscopic structure, driven by temperature and daylight, and does pretty well with the day-to-day variations which are probably more driven by rainfall and the day of the week.

There's a few big misses, though. Let's look at the days where our model misses the mark by over 1000 trips:

On July 11th, a Tuesday, our model expects a normal summer day but the counted number of trips drops of precipitously. The weather data for that says 20 degrees and no rain, so I'm not sure what's going on. I've looked at my source data and don't see anything out of the ordinary, but I suspect there was a data acquisition issue that day.

On August 12th, a Saturday, the model understates the number of riders by a large margin. There was 0.2 mm of rain measured on this day, so the model is treating it as a rainy day, but perhaps it only rained a bit overnight and was clear the rest of the day.

Finally, on October 12th, a Thursday, the model again undercounts the number of trips, only expecting ~200 trips when in reality there over a thousand! There was 35 mm of rain measured that day, so even though the model expects the number of trips to keep decreasing linearly with rain, in practice if someone is going to bike in 20 mm of rain they're probably also going to bike in 30 mm of rain. Our model doesn't account for this.

There's some other potentially nonlinear effects that we're not including here. During the winter in Vancouver, the coldest days are often clear and sunny. I wonder if as we get into December and January, the temperature trend might reverse and we'll see more trips on the coldest days. If that's the case, we may need a more complex model to really describe how weather affects bike share users.

&lt;em&gt;All the source code used for data acquisition and analysis in this post is available on my &lt;a href="https://github.com/mjarrett/mobi"&gt;github page&lt;/a&gt;.&lt;/em&gt;

&lt;em&gt;To see more posts like this, follow me on twitter &lt;a href="https://twitter.com/MikeJarrett_"&gt;@MikeJarrett_&lt;/a&gt;.&lt;/em&gt;</description><category>bikes</category><category>bikeshare</category><category>datavis</category><category>mobi</category><category>python</category><category>Science</category><guid>https://notes.mikejarrett.ca/what-really-affects-bikeshare-use-in-vancouver/</guid><pubDate>Wed, 22 Nov 2017 07:32:26 GMT</pubDate></item></channel></rss>