import numpy as np import hvplot.pandas # noqa import hvplot.dask # noqa hvplot.extension('matplotlib') from hvplot.sample_data import us_crime, airline_flights crime = us_crime.read() print(type(crime)) crime.head() flights = airline_flights.to_dask().persist() print(type(flights)) flights.head() crime.hvplot.line(x='Year', y='Violent Crime rate') crime.hvplot(x='Year', y='Violent Crime rate', kind='scatter') flight_subset = flights[flights.carrier.isin(['OH', 'F9'])] flight_subset.hvplot(x='distance', y='depdelay', by='carrier', kind='scatter', alpha=0.2, persist=True) crime.hvplot(x='Year', y=['Violent Crime rate', 'Robbery rate', 'Burglary rate'], value_label='Rate (per 100k people)') crime.hvplot.area(x='Year', y=['Robbery', 'Aggravated assault']) crime.hvplot.area(x='Year', y=['Aggravated assault', 'Robbery'], stacked=False, alpha=0.4) delay_min_max = flights.groupby(['day', 'carrier'])['carrier_delay'].mean().groupby('day').agg([np.min, np.max]) delay_mean = flights.groupby('day')['carrier_delay'].mean() delay_min_max.hvplot.area(x='day', y='amin', y2='amax', alpha=0.2) * delay_mean.hvplot() crime.hvplot.bar(x='Year', y='Violent Crime rate', rot=90, width=900) crime.hvplot.bar(x='Year', y=['Violent crime total', 'Property crime total'], stacked=True, rot=90, width=900, legend='top_left') crime.hvplot.scatter(x='Violent Crime rate', y='Burglary rate', c='Year') crime.hvplot.step(x='Year', y=['Robbery', 'Aggravated assault']) flights.hvplot.hexbin(x='airtime', y='arrdelay', width=600, height=500, logz=True); crime.hvplot.bivariate(x='Violent Crime rate', y='Burglary rate', width=600, height=500) flights.compute().hvplot.heatmap(x='day', y='carrier', C='depdelay', reduce_function=np.mean, colorbar=True).opts(show_values=False) crime.hvplot.table(columns=['Year', 'Population', 'Violent Crime rate'], width=400) crime.hvplot.hist(y='Violent Crime rate') columns = ['Violent Crime rate', 'Property crime rate', 'Burglary rate'] crime.hvplot.hist(y=columns, bins=50, alpha=0.5, legend='top', height=400) flight_subset = flights[flights.carrier.isin(['AA', 'US', 'OH'])] flight_subset.hvplot.hist('depdelay', by='carrier', bins=20, bin_range=(-20, 100), width=300, subplots=True); crime.hvplot.kde(y='Violent Crime rate') columns=['Violent Crime rate', 'Property crime rate', 'Burglary rate'] crime.hvplot.kde(y=columns, alpha=0.5, value_label='Rate', legend='top_right') flight_subset = flights[flights.carrier.isin(['AA', 'US', 'OH'])] flight_subset.hvplot.kde('depdelay', by='carrier', xlim=(-20, 70), width=300, subplots=True) crime.hvplot.box(y='Violent Crime rate') columns=['Burglary rate', 'Larceny-theft rate', 'Motor vehicle theft rate', 'Property crime rate', 'Violent Crime rate'] crime.hvplot.box(y=columns, group_label='Crime', legend=False, value_label='Rate (per 100k)', invert=True) flight_subset = flights[flights.carrier.isin(['AA', 'US', 'OH'])] flight_subset.hvplot.box('depdelay', by='carrier', ylim=(-10, 70)); crime.hvplot(x='Year', y='Violent Crime rate') * crime.hvplot.scatter(x='Year', y='Violent Crime rate', c='k') (crime.hvplot.bar(x='Year', y='Violent Crime rate', rot=90, width=550) + crime.hvplot.table(['Year', 'Population', 'Violent Crime rate'], width=420)) flights.hvplot.scatter(x='distance', y='airtime', datashade=True) flights.hvplot.violin(y='depdelay', by='carrier', groupby='dayofweek', ylim=(-20, 60), height=500)