Skip to content

Instantly share code, notes, and snippets.

View danielballan's full-sized avatar

Dan Allan danielballan

View GitHub Profile
@danielballan
danielballan / ccu.py
Created September 19, 2012 15:48
Corning Credit Union parser
"""
PURPOSE: Parse a pile of 'spreadsheet' files downloaded from
Corning Credit Union eBranch.
FEAUTURES: - Parse and combine financial records from a list of raw
files, converting the data into convenient types.
- Plot stuff.
EXAMPLE USAGE:
import ccu
@danielballan
danielballan / gist:5304277
Created April 3, 2013 19:07
Error on import
/home/dallan/pandas-danielballan/pandas/__init__.py in <module>()
23
24 # let init-time option registration happen
---> 25 import pandas.core.config_init
26
27 from pandas.core.api import *
/home/dallan/pandas-danielballan/pandas/core/config_init.py in <module>()
2 from pandas.core.config import (is_int, is_bool, is_text, is_float,
3 is_instance_factory,is_one_of_factory)
@danielballan
danielballan / gist:8531266
Created January 20, 2014 23:09
forgivness vs. permission
In [4]: def forgiveness(x):
try:
x.plugins.append(1)
except AttributeError:
x.plugins = [1]
...:
In [5]: def permission(x):
if not hasattr(x, 'plugins'):
x.plugins = []
@danielballan
danielballan / gmail.py
Created February 6, 2014 16:02
Gmail Parser
#!/usr/bin/python
import sys
import re
from dateutil.parser import parse
import email
import html2text
import MySQLdb
from itertools import *
@danielballan
danielballan / gist:11178744
Created April 22, 2014 13:15
Traceback for pandas SQL timedelta issue
In [27]: df.to_sql('bar', engine, index=False)
---------------------------------------------------------------------------
StatementError Traceback (most recent call last)
<ipython-input-27-7476a9ea602a> in <module>()
----> 1 df.to_sql('bar', engine, index=False)
/Users/danielallan/Documents/Repos/pandas-danielballan/pandas/core/generic.py in to_sql(self, name, con, flavor, if_exists, index, index_label)
940 sql.to_sql(
941 self, name, con, flavor=flavor, if_exists=if_exists, index=index,
--> 942 index_label=index_label)
@danielballan
danielballan / leheny.mplstyle
Last active August 3, 2016 14:13
Leheny Lab "House Style" for Python matplotlib plots
# This is Dan Allan's setting of Professor Robert Leheny's plotting style preferences.
# Updated October 2014
#
# Invoke in Python matplotlib like so:
#
# import matplotlib as mpl
#
# mpl.style.use('https://gist.github.com/danielballan/be066529de85e87a5fe7/raw')
#
# This feature is only available in matplotlib version 1.4 or higher.
@danielballan
danielballan / gist:b1ede9b5eb7b33cbf594
Last active August 29, 2015 14:03
Parse Zetasizer data
"""
Copyright 2014 Dan Allan
Read the data from a Zetasizer output file and return the intensity as
as a function of frequency in a spreadsheet-like object (pandas DataFrame)
that can exported to any convenient format.
This is only lightly tested.
"""
@danielballan
danielballan / cropper.py
Created July 4, 2014 01:18
Interactive cropping tool for the IPython notebook
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import six
import matplotlib as mpl
import matplotlib.pyplot as plt
import matplotlib.path as mpath
import matplotlib.patches as mpatches
from IPython.html import widgets
@danielballan
danielballan / gist:ba97de07fe9595df0f6f
Created July 16, 2014 13:34
Traceback of a failed conda build on Windows 64-bit. This succeeded on Windows 32-bit.
running install
running bdist_egg
running egg_info
creating PIMS.egg-info
writing PIMS.egg-info\PKG-INFO
writing top-level names to PIMS.egg-info\top_level.txt
writing dependency_links to PIMS.egg-info\dependency_links.txt
writing manifest file 'PIMS.egg-info\SOURCES.txt'
reading manifest file 'PIMS.egg-info\SOURCES.txt'
writing manifest file 'PIMS.egg-info\SOURCES.txt'
# Daniel B. Allan
# August 2014
# Robert L. Leheny Lab, JHU Dept. of Physics & Astronomy
"""
Capture an image from a NI frame grabber.
Adapted from code posted by Oliver W. at
http://stackoverflow.com/questions/17095359