~vesto/gists

5c8240f4ebb0b8e91b64f4c697582b155f21e9fa — Steve Gattuso 1 year, 3 months ago
add citibike python
1 files changed, 25 insertions(+), 0 deletions(-)

A citibike-fetch.py
A  => citibike-fetch.py +25 -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)