Skip to content

Instantly share code, notes, and snippets.

@mwaskom
mwaskom / bootstrap_simulations.ipynb
Last active August 29, 2015 13:55
Demonstration of problems with bootstrap resampling when data are structured into sampling units with repeated measures, and an approach to account for those problems.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mwaskom
mwaskom / randps1.py
Last active August 29, 2015 13:56
BASH prompt with current directory and git repository branch/state in a different color for each terminal window.
#! /usr/bin/env python
"""Randomly colored, useful BASH prompt.
Put this on your PATH `chmod u+x` it, and add
export PS1=`randps1.py`
to your .bash_profile file.
"""
from random import choice
@mwaskom
mwaskom / r_vs_python_3_update.ipynb
Created March 14, 2014 18:43
Updated version of the R vs. Python challenge notebook
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mwaskom
mwaskom / argparse_demo.py
Created March 20, 2014 04:09
Argparse demonstration
import argparse
def parse_arglist(args):
parser = argparse.ArgumentParser()
parser.add_argument("-a", nargs="*", type=int)
return parser.parse_args(args)
print parse_arglist(["-a", "1", "2"])
# Prints Namespace(a=[1, 2])
@mwaskom
mwaskom / facetgrid_histogram
Last active August 29, 2015 13:57
Seaborn FacetGrid histogram example
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@mwaskom
mwaskom / mcfrank_analysis.py
Created April 27, 2014 02:18
Simple translation of Mike's example R script to Python
import pandas as pd
import seaborn as sns
imoprt statsmodels.api as sm
#### 1. read in data
#d <- read.csv("data/all_data.csv")
d = pd.read_csv("data/all_data.csv")
#### 2. aggregate for each subject and then across subjects
@mwaskom
mwaskom / beg_forgiveness.py
Created May 23, 2014 03:30
Better to beg forgiveness than ask permission.
def vectorize2(f):
def g(x):
try:
return [f(x) for x in x]
except TypeError:
return f(x)
return g
@mwaskom
mwaskom / mosaic.ipynb
Created May 30, 2014 23:44
Simple examples using the Mosaic class from moss
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mwaskom
mwaskom / exploratory_logit.ipynb
Last active August 29, 2015 14:02
Simple exploratory logistic regression plots
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mwaskom
mwaskom / matplotlib_bakeoff.ipynb
Last active August 29, 2015 14:04
Cleaner combination of matplotlib and seaborn for the Wordpress plot bakeoff
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.