Skip to content

Instantly share code, notes, and snippets.

View jcrist's full-sized avatar

Jim Crist-Harif jcrist

View GitHub Profile
@jcrist
jcrist / reddit_to_castra.py
Created August 18, 2015 21:56
Convert reddit comment data to castra
import ujson
from datetime import datetime
import pandas as pd
from toolz import partition_all, dissoc
from castra import Castra
def to_json(line):
blob = ujson.loads(line)
date = blob['created_utc']
@jcrist
jcrist / parametric_modules.py
Created August 30, 2015 20:47
Parametric Modules and functors in Python
from types import ModuleType
import sys
import inspect
from contextlib import contextmanager
class LocalImportFinder(object):
def find_module(self, fullname, path=None):
if path:
return None
@jcrist
jcrist / airline_to_castra.py
Created October 2, 2015 18:46
Convert airline data to castra
from __future__ import print_function
import pandas as pd
from castra import Castra
from toolz import peek
def make_frame(year):
path = '{0}.csv'.format(year)
cols = ['year', 'month', 'day_of_month', 'day_of_week', 'deptime',
'crs_deptime', 'arrtime', 'crs_arrtime', 'unique_carrier',
'flight_num', 'tail_num', 'actual_elapsed_time',
@jcrist
jcrist / bytecode.ipynb
Last active December 11, 2015 18:51
Manipulating Python Bytecode with Codetransformer
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jcrist
jcrist / taxi.ipynb
Created January 11, 2016 07:19
Demonstration of basic transfer functions
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jcrist
jcrist / Example_use.md
Created January 19, 2016 00:43
Generated functions in numba
In [1]: from generated import generated

In [2]: import numba as nb

In [3]: @generated(nopython=True)
   ...: def foo(x, y):
   ...:     if isinstance(x, nb.types.Integer):
   ...:         return lambda x, y: x + y
 ...: else:
@jcrist
jcrist / colormaps.ipynb
Last active February 19, 2021 03:52
Using colormaps with datashader
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jcrist
jcrist / dask_interface.ipynb
Created April 8, 2016 19:10
Dask Interface
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jcrist
jcrist / dominion.ipynb
Last active May 5, 2016 21:36
Logistic Regression in Dask
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.