import pandas as pd import numpy as np import holoviews as hv from holoviews import opts hv.extension('bokeh') station_info = pd.read_csv('../assets/station_info.csv') station_info.head() scatter = hv.Scatter(station_info, 'services', 'ridership') scatter print(scatter) layout = scatter + hv.Histogram(np.histogram(station_info['opened'], bins=24), kdims=['opened']) layout print(layout) taxi_dropoffs = {hour:arr for hour, arr in np.load('../assets/hourly_taxi_data.npz').items()} print('Hours: {hours}'.format(hours=', '.join(taxi_dropoffs.keys()))) print('Taxi data contains {num} arrays (one per hour).\nDescription of the first array:\n'.format(num=len(taxi_dropoffs))) np.info(taxi_dropoffs['0']) bounds = (-74.05, 40.70, -73.90, 40.80) image = hv.Image(taxi_dropoffs['0'], ['lon','lat'], bounds=bounds) points = hv.Points(station_info, ['lon','lat']).opts(color="red") image + image * points dictionary = {int(hour):hv.Image(arr, ['lon','lat'], bounds=bounds) for hour, arr in taxi_dropoffs.items()} hv.HoloMap(dictionary, kdims='Hour') holomap = hv.HoloMap(dictionary, kdims='Hour') print(holomap) holomap.select(Hour={3,6,9}).layout() hotspot = points.select(lon=(-73.99, -73.96), lat=(40.75,40.765)) composition = holomap * hotspot composition.opts( opts.Image(xrotation=90), opts.Points(color='red', marker='v', size=6)) composition.select(Hour=7) hotspot.data hv.save(composition, 'holomap.html') hv.save(composition.last, 'image.html')