<jupyter_start><jupyter_text>Counting bikes in ZurichThis notebook counts weekly bike riders who pass a certain bike counter.<jupyter_code>import os
import requests

import matplotlib.pyplot as plt
import pandas as pd<jupyter_output><empty_output><jupyter_text>Parameters of this notebook. Which year and which location should we produe plots for?<jupyter_code>year = 2015
location = "ECO09113499"<jupyter_output><empty_output><jupyter_text>Download the data if it isn't present already.<jupyter_code>BASE = "https://data.stadt-zuerich.ch/dataset/verkehrszaehlungen_werte_fussgaenger_velo/resource/"
URLS = {
    2015: BASE + "5c994056-eda6-48c5-8e61-28e96bcd04a3/download/2015verkehrszaehlungenwertefussgaengervelo.csv",
    2014: BASE + "bd2c9dd9-5b05-4303-a4c9-4a9f5b73e8f7/download/2014verkehrszaehlungenwertefussgaengervelo.csv",
    2016: BASE + "ed354dde-c0f9-43b3-b05b-08c5f4c3f65a/download/2016_verkehrszaehlungen_werte_fussgaenger_velo.csv"
    }

if year not in URLS:
    raise ValueError("Year has to be one of 2014, 2015 "
                     "not %s." % year)

fname = "bikes-%i.csv" % year
if not os.path.exists(fname):
    with requests.get(URLS[year], stream=True) as r:
        r.raise_for_status()
        with open(fname, 'wb') as w:
            for chunk in r.iter_content(chunk_size=65535):
                w.write(chunk)<jupyter_output><empty_output><jupyter_text>Sanity check that the first few lines look alright.<jupyter_code>!head $fname<jupyter_output>﻿"ObjectID","Datum","Standort","Velo_in","Velo_out","Fuss_in","Fuss_out"

170217,2015-03-06T17:15:00,"ECO09022739",10,5,,

170218,2015-03-06T17:30:00,"ECO09022739",6,10,,

170219,2015-03-06T17:45:00,"ECO09022739",7,5,,

170220,2015-03-06T18:00:00,"ECO09022739",8,19,,

170221,2015-03-06T18:15:00,"ECO09022739",13,6,,

170222,2015-03-06T18:30:00,"ECO09022739",6,12,,

170223,2015-03-06T18:45:00,"ECO09022739",1,6,,

170224,2015-03-06T19:00:00,"ECO09022739",2,8,,

170225,2015-03-06T19:15:00,"ECO09022739",5,1,,<jupyter_text>Load the data int oa dataframe. The index column is called "Datum".<jupyter_code>data = pd.read_csv(fname, parse_dates=True, dayfirst=True, index_col='Datum')

# filter by location
data = data[data.Standort == location]

# subselect only the Velo data
data = data[["Velo_in", "Velo_out"]]

data['Total'] = data.Velo_in + data.Velo_out
# rename for easier plotting
data.columns = ["North", "South", "Total"]

# Compute weekly rides by summing over the 15m intervals
weekly = data.resample('W').sum()
weekly.plot()

plt.savefig("weekly-%s.png" % year)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1381172839506173, 'fraction_numerical': 0.14776234567901234, 'mean_word_length': 5.700258397932816, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 20, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '415539', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1282, 'n_tokens_neox': 1056, 'n_words': 171, 'path': 'example/bikes.ipynb', 'repo_name': 'MattForshaw/reproducible-science-tools', 'size': '2592'}