Skip to content

Instantly share code, notes, and snippets.

View draperjames's full-sized avatar

James Draper draperjames

View GitHub Profile
@draperjames
draperjames / DataFrameGUI.py
Created November 17, 2016 21:56 — forked from jsexauer/DataFrameGUI.py
A sophisticated GUI to interact with DataFrame objects
"""
DataFrameTable
==============
Quick and Dirty Qt app to view pandas DataFrames. Includes sorting and
filterting.
Based on qtpandas in pandas sandbox module, by Jev Kuznetsov
Usage:
@draperjames
draperjames / multiRegExOr.py
Last active May 22, 2017 14:02
lil python function for "OR"ed regex terms from a given list.
def multiRegExOr(term_list):
"""Returns a singles string of "OR"ed regex terms from a given list.
Parameters
----------
term_list: list
List of regular expressions.
Returns
-------
@draperjames
draperjames / easy_bokeh_display.py
Last active January 11, 2017 15:32
easy bokeh display in jupyter notebook
%env BOKEH_RESOURCES=inline ipython notebook
from bokeh.io import show, output_notebook
from bokeh.plotting import ColumnDataSource, figure
from bokeh.models import HoverTool, Range1d
output_notebook()
fig = figure(tools=[HoverTool(tooltips=[("html", "@html{safe}")])])
fig.quad(left="left", top="top", bottom="bottom", right="right",
source=ColumnDataSource({"left": [1,3], "bottom": [1,3],
@draperjames
draperjames / pandas_dbms.py
Created May 10, 2017 20:33 — forked from catawbasam/pandas_dbms.py
Python PANDAS : load and save Dataframes to sqlite, MySQL, Oracle, Postgres
# -*- coding: utf-8 -*-
"""
LICENSE: BSD (same as pandas)
example use of pandas with oracle mysql postgresql sqlite
- updated 9/18/2012 with better column name handling; couple of bug fixes.
- used ~20 times for various ETL jobs. Mostly MySQL, but some Oracle.
to do:
save/restore index (how to check table existence? just do select count(*)?),
finish odbc,
@draperjames
draperjames / jupyter_notebook_select_files_button.py
Created May 22, 2017 14:00
Select files button for Jupyter notebook
import traitlets
from IPython.display import display
from ipywidgets import widgets
from tkinter import Tk, filedialog
class SelectFilesButton(widgets.Button):
"""A file widget that leverages tkinter.filedialog."""
def __init__(self, *args, **kwargs):
@draperjames
draperjames / timestamp_widget.py
Created June 15, 2017 14:55
ipywidgets timestamp for your Jupyter Notebook
from datetime import datetime
from ipywidgets import widgets
from dominate import tags
def timestamp():
"""Return a ipywidget timestamp."""
ts = tags.h4("{:%I:%M:%S %p %A %B %d %Y}".format(datetime.now()))
ts_widget = widgets.HTML(ts.render())
return ts_widget
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@draperjames
draperjames / jslink_cant_sync_subclassed_button_widgets.ipynb
Last active August 3, 2017 21:30
jslink cant sync subclassed button widgets
@draperjames
draperjames / jslinked_upload_and_run_widgets.ipynb
Created August 3, 2017 21:59
ipywidgets upload files and run somekind of process on them
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@draperjames
draperjames / ipywidgets_selection_container_as_dict.ipynb
Created August 8, 2017 20:52
ipywidgets _SelectionContainer.as_dict
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.