This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*.swp | |
*.db | |
*.code-workspace | |
venv | |
vevn | |
input | |
node_modules | |
bchApp | |
output | |
*.csv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Create a group | |
CREATE ROLE readaccess; | |
-- Grant access to existing tables | |
GRANT USAGE ON SCHEMA public TO readaccess; | |
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess; | |
-- Grant access to future tables | |
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Byte-compiled / optimized / DLL files | |
__pycache__/ | |
*.py[cod] | |
*$py.class | |
*.db | |
analysis/**/*.csv | |
input/ | |
ouput/ | |
venv | |
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'); | |
if (process.argv.length <= 2) { | |
console.log("Usage: " + __filename + " path/to/directory"); | |
process.exit(-1); | |
} | |
var path = process.argv[2]; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bar_click = alt.selection_single(fields=['weather'], on="click") | |
brush = alt.selection(type='interval', encodings=['x']) | |
## See functionality in vega editor http://bit.ly/2o28r02 | |
color = alt.Color( | |
field='weather', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pygal | |
from pygal.style import Style | |
custom_style = Style( | |
colors=colors, | |
legend_font_size = 4, | |
title_font_size = 5, | |
value_font_size=4) | |
sources_pygal_pie = pygal.Pie(width=150, height=150, style=custom_style, legend_box_size=4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from altair import Row, Column, Chart, Text, Scale, Color | |
source_altair_chart = Chart(source_df).mark_text( | |
applyColorToBackground=True | |
).mark_bar().encode(x='FoodCode',y='Source', color=Color('Source', scale=Scale(range=colors))) | |
#"scale": {"scheme": "bluepurple"} doesn't work | |
flavor_altair_chart = Chart(flavor_df).mark_text( | |
applyColorToBackground=True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%%opts Bars [xrotation=90 width=600 height=500 show_legend=False tools=['hover'] invert_axes=True ] | |
%%opts Bars (fill_color=Cycle('Spectral')) | |
%%opts Layout [shared_axes=False] | |
import holoviews as hv | |
hv.extension('bokeh') | |
pie_raw_holo_table = hv.Table(pie_raw, kdims=['Source', 'FoodCode']) | |
sources_chart = pie_raw_holo_table.aggregate('Source', function=np.count_nonzero).to.bars(group='Sources of Pie Consumption ') | |
flavors_chart = pie_raw_holo_table.aggregate('FoodCode', function=np.count_nonzero).to.bars(group='Flavors of Pie Consumption ') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Calculate the Angles | |
from math import pi | |
source_pct_df = pd.DataFrame(source_counts/source_counts.sum()).reset_index().sort_values(by='FoodCode') | |
flavor_pct_df = pd.DataFrame(flavor_counts/flavor_counts.sum()).reset_index().sort_values(by='Source') | |
source_starts = [p*2*pi for p in source_pct_df.cumsum().FoodCode[:-1]] | |
source_ends = [p*2*pi for p in source_pct_df.cumsum().FoodCode[1:]] | |
source_legends = source_pct_df.Source.values.tolist()[1:] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cufflinks as cf | |
# Correct datatypes cufflinks does not support CategoryType so we make them strings and rebuild the dataframe. | |
source_df = pd.DataFrame(source_counts).reset_index() | |
flavor_df = pd.DataFrame(flavor_counts).reset_index() | |
source_pie = source_df.iplot(kind='pie', labels='Source', values='FoodCode', colors=colors, title='Sources of Pie') | |
flavor_pie = source_df.iplot(kind='pie', labels='Source', values='FoodCode', colors=colors, title='Flavors of Pie') | |
display(source_pie, flavor_pie) |
NewerOlder