Source: https://data.london.gov.uk/dataset/london-underground-performance-reports
In [1]:
import pandas
from cartoframes.auth import set_default_credentials
from cartoframes.data.services import Geocoding
set_default_credentials('creds.json')
In [2]:
local_file_path = '../files/london_stations.xls'
df = pandas.read_excel(local_file_path, header=6, sheet_name=1)
df.head()
Out[2]:
In [3]:
df = df.rename(columns={
"Saturday.1": "saturday_exit",
"Sunday.1": "sunday_exit",
"Weekday.1": "weekday_exit",
"Saturday": "saturday_entry",
"Sunday": "sunday_entry",
"Weekday": "weekday_entry"
})
df.head()
Out[3]:
In [4]:
gc = Geocoding()
london_stations_gdf, london_stations_metadata = gc.geocode(
df,
street='Borough',
city={'value': 'London'},
country={'value': 'United Kingdom'}
)
In [5]:
london_stations_gdf.head()
Out[5]:
In [6]:
from cartoframes.viz import Map, Layer
Map(Layer(london_stations_gdf), viewport={'zoom': 10, 'lat': 51.53, 'lng': -0.09})
Out[6]: