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
STOPCHARS = ['a', 'b', 'c', 'd'] | |
def normalize_word(word, stops=None): | |
word = word.strip().lower() | |
if stops: | |
word = ''.join([char for char in word if char not in stops]) | |
return word |
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
stopchars = ['a', 'b', 'c', 'd'] | |
word = 'abracadabra' | |
word = word.strip().lower() | |
word = ''.join([char for char in word if char not in stops]) | |
word |
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
""" | |
Code described in Medium post https://medium.com/@schaun.wheeler/codify-your-workflow-377f5f8bf4c3 | |
Copyright (c) 2018 Valassis Digital under the terms of the BSD 3-Clause license. | |
""" | |
def add_source(self, data, label, column_name=None, **kwargs): | |
# process data into x and y coordinates | |
if type(data) == DataFrame: |
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
""" | |
Code described in Medium post https://medium.com/@schaun.wheeler/codify-your-workflow-377f5f8bf4c3 | |
Copyright (c) 2018 Valassis Digital under the terms of the BSD 3-Clause license. | |
""" | |
def add_layer(self, source_label, bokeh_model, tooltips=None, **kwargs): | |
if self.plot is None: | |
raise AssertionError('self.plot is null; call `self.prepare_plot`.') | |
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
""" | |
Code described in Medium post https://medium.com/@schaun.wheeler/codify-your-workflow-377f5f8bf4c3 | |
Copyright (c) 2018 Valassis Digital under the terms of the BSD 3-Clause license. | |
""" | |
def prepare_plot(self, plot_width=700, plot_height=None, zoom=None, map_type='hybrid', **kwargs): | |
zoom_level, lat_center, lng_center, auto_plot_height = self._estimate_zoom_level(plot_width) | |
if plot_height is None: | |
plot_height = auto_plot_height |
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
""" | |
Code described in Medium post https://medium.com/@schaun.wheeler/codify-your-workflow-377f5f8bf4c3 | |
Copyright (c) 2018 Valassis Digital under the terms of the BSD 3-Clause license. | |
""" | |
from math import sin, pi, log, floor | |
from shapely.wkt import loads, dumps | |
from shapely.geometry import Polygon, Point, MultiPolygon, LineString, MultiLineString, MultiPoint, GeometryCollection | |
from bokeh.io import output_notebook, show, output_file, reset_output, save |
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
DROP FUNCTION IF EXISTS pivotcode(varchar, varchar, varchar, varchar, varchar, varchar); | |
create or replace function pivotcode (tablename varchar, resultname varchar, rowc varchar, colc varchar, cellc varchar, celldatatype varchar) | |
returns VOID language plpgsql as $$ | |
declare | |
dynsql1 varchar; | |
dynsql2 varchar; | |
columnlist varchar; | |
begin | |
-- 1. retrieve list of column names. | |
dynsql1 = 'select string_agg(distinct ''"''||'||colc||'||''" '||celldatatype||''','','' order by ''"''||'||colc||'||''" '||celldatatype||''') from '||tablename||';'; |
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 pandas import DataFrame | |
from bokeh.models.axes import CategoricalAxis | |
from bokeh.models import Plot, ColumnDataSource | |
from bokeh.models.ranges import FactorRange, Range1d | |
from bokeh.models.glyphs import Circle | |
from bokeh.models.widgets.markups import PreText | |
from bokeh.layouts import Column | |
from bokeh.models.widgets.inputs import Select | |
from bokeh.plotting import curdoc | |
from bokeh.models.callbacks import CustomJS |
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 pandas import DataFrame | |
from bokeh.models.axes import CategoricalAxis | |
from bokeh.models import Plot, ColumnDataSource | |
from bokeh.models.ranges import FactorRange | |
from bokeh.models.glyphs import Circle | |
from bokeh.models.widgets.markups import PreText | |
from bokeh.layouts import Column | |
from bokeh.models.widgets.inputs import Select | |
from bokeh.plotting import curdoc |
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 bokeh.properties import Instance, Bool, String | |
from bokeh.models.widgets.buttons import Button, Toggle | |
from bokeh.models.widgets.markups import Paragraph | |
from bokeh.models.widgets.layouts import VBox, HBox, VBoxForm | |
from bokeh.models.widgets.inputs import Select | |
from bokeh.server.app import bokeh_app | |
from bokeh.server.utils.plugins import object_page | |
from bokeh.plotting import curdoc | |