spellbook

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 5c8240f4ebb0b8e91b64f4c697582b155f21e9fa
Author: Steve Gattuso <steve@stevegattuso.me>
Date:   Sun, 26 Feb 2023 21:18:08 +0100

add citibike python

Diffstat:
Acitibike-fetch.py | 25+++++++++++++++++++++++++
1 file changed, 25 insertions(+), 0 deletions(-)

diff --git a/citibike-fetch.py b/citibike-fetch.py @@ -0,0 +1,25 @@ +""" + A simple script for fetching a CSV of active Citibike stations +""" +import pandas as pd +import requests + +resp = ( + requests + .get('https://gbfs.citibikenyc.com/gbfs/en/station_information.json') + .json() +) + +interesting_columns = [ + 'name', 'station_id', 'lat', 'lon', 'region_id', + 'electric_bike_surcharge_waiver', 'capacity', 'has_kiosk', + 'eightd_has_key_dispenser', 'station_type', +] + +stations = ( + pd.DataFrame(resp['data']['stations']) + [interesting_columns] +) + +stations.to_csv('./citibike.csv') +print(stations)