import pandas as pd
import altair as alt
import os
df = pd.read_csv('data/average_internet_speed.csv',parse_dates=['quarter'])
# split upload and download speed in 5 bins
bins = [1, 51, 102, 152, 203,254]
labels = [50, 101, 152, 203,254]
df['binned upload speed'] = pd.cut(x = df['average upload speed'], bins = bins, labels = labels, include_lowest = True)
df['binned download speed'] = pd.cut(x = df['average download speed'], bins = bins, labels = labels, include_lowest = True)
# drop null values
df.dropna(inplace=True)
# the shape of a hexagon
hexagon = "M0,-2.3094010768L2,-1.1547005384 2,1.1547005384 0,2.3094010768 -2,1.1547005384 -2,-1.1547005384Z"
size = 25
# Count of distinct x features
xFeaturesCount = 4
# Count of distinct y features
yFeaturesCount = 5
# use mark_point(shape=hexagon) to draw hexagons
# encode binned download speed in the y channel
# calculate the position on the x axis through transform_calculate()
#chart = alt.Chart(df)
# uncomment the following lines to show the chart
#chart.save('chart.html')
#os.system('cat chart.html')