citibike-fetch.py (546B)
1 """ 2 A simple script for fetching a CSV of active Citibike stations 3 """ 4 import pandas as pd 5 import requests 6 7 resp = ( 8 requests 9 .get('https://gbfs.citibikenyc.com/gbfs/en/station_information.json') 10 .json() 11 ) 12 13 interesting_columns = [ 14 'name', 'station_id', 'lat', 'lon', 'region_id', 15 'electric_bike_surcharge_waiver', 'capacity', 'has_kiosk', 16 'eightd_has_key_dispenser', 'station_type', 17 ] 18 19 stations = ( 20 pd.DataFrame(resp['data']['stations']) 21 [interesting_columns] 22 ) 23 24 stations.to_csv('./citibike.csv') 25 print(stations)