This file contains hidden or 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
def d64(start, end): | |
""" find the midpoints of two dates and return as numpy int64""" | |
midpoint = start + (end-start)/2 | |
print(start, end, midpoint) | |
return np.datetime64(midpoint).astype('datetime64[ms]').view(np.int64) | |
xrange = Range1d(q.start_dt,q.end_dt) | |
plot = figure(plot_width=850, plot_height=100, x_range=xrange) | |
plot.xaxis[0].ticker = DatetimeTicker() |
This file contains hidden or 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 pypyodbc | |
import pandas as pd | |
CONNECTION_STRING = """ | |
Driver={{{DRIVER}}}; | |
Server={SERVER}; | |
Database={DATABASE}; | |
""".format(**locals()) | |
df = pd.read_sql(con=pypyodbc.connect(CONNECTION_STRING), sql=sql) |
This file contains hidden or 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.models.callbacks import CustomJS | |
jscode=""" | |
range.set('start', parseInt(%s)); | |
range.set('end', parseInt(%s)); | |
""" | |
yrange = subplot.y_range | |
yrange.start, yrange.end = 0, plot_height | |
subplot.y_range.callback = CustomJS( |
This file contains hidden or 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
# http://stackoverflow.com/questions/34898525/generate-list-of-months-between-interval-in-python | |
from datetime import datetime, timedelta | |
from collections import OrderedDict | |
dates = ["2014-10-10", "2016-01-07"] | |
start, end = [datetime.strptime(_, "%Y-%m-%d") for _ in dates] | |
OrderedDict(((start + timedelta(_)).strftime(r"%b-%y"), None) for _ in xrange((end - start).days)).keys() | |
#['Oct-14', 'Nov-14', 'Dec-14', 'Jan-15', 'Feb-15', 'Mar-15', 'Apr-15', | |
# 'May-15', 'Jun-15', 'Jul-15', 'Aug-15', 'Sep-15', 'Oct-15', 'Nov-15', |
This file contains hidden or 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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |