Last active
November 25, 2021 03:02
-
-
Save stevenleeg/c9815da685ea0736f77557032b222d48 to your computer and use it in GitHub Desktop.
A simple script for fetching a CSV of active Citibike stations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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