Skip to content

Instantly share code, notes, and snippets.

View howardhamilton's full-sized avatar
💭
Tap tap tap...is this mic on?

Howard Hamilton howardhamilton

💭
Tap tap tap...is this mic on?
  • Atlanta, GA, USA
View GitHub Profile
@bsweger
bsweger / useful_pandas_snippets.md
Last active April 19, 2024 18:04
Useful Pandas Snippets

Useful Pandas Snippets

A personal diary of DataFrame munging over the years.

Data Types and Conversion

Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)

@baldwint
baldwint / hinton.py
Created September 13, 2013 00:46
Hinton diagrams in matplotlib
"""
Hinton diagrams in matplotlib.
A Hinton diagram is useful for visualizing a matrix of signed weights.
In the diagram, each matrix element is represented by a square whose
color indicates the sign and whose area represents the magnitude.
"""
import matplotlib.patches as mpatches
@jaytaylor
jaytaylor / camel_case_to_snake_case.py
Created September 6, 2012 21:41
Convert camel-case to snake-case in python.
#!/usr/bin/env python
"""
Convert camel-case to snake-case in python.
e.g.: CamelCase -> snake_case
Relevant StackOverflow question: http://stackoverflow.com/a/1176023/293064
"""
@mtigas
mtigas / middleware.py
Created February 13, 2012 01:14
An SSL-enforcing middleware
from django.conf import settings
from django.http import HttpResponsePermanentRedirect, get_host
class ForceSSLMiddleware(object):
"""
Redirects all (non-DEBUG) requests to go through SSL.
Picks up the `HTTP_X_FORWARDED_PROTO` proxy header set by Heroku.
Also sets the "Strict-Transport-Security" header for 600 seconds so that
@agramfort
agramfort / lowess.py
Last active August 16, 2023 06:19
LOWESS : Locally weighted regression
"""
This module implements the Lowess function for nonparametric regression.
Functions:
lowess Fit a smooth nonparametric regression curve to a scatterplot.
For more information, see
William S. Cleveland: "Robust locally weighted regression and smoothing
scatterplots", Journal of the American Statistical Association, December 1979,