Skip to content

Instantly share code, notes, and snippets.

@stevenleeg
Last active November 25, 2021 03:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevenleeg/c9815da685ea0736f77557032b222d48 to your computer and use it in GitHub Desktop.
Save stevenleeg/c9815da685ea0736f77557032b222d48 to your computer and use it in GitHub Desktop.
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment