Skip to content

Instantly share code, notes, and snippets.

@s-boardman
s-boardman / pandas heatmaps
Last active August 22, 2017 18:55
Heatmap functions for Pandas dataframes.
"""Plots a Pandas dataframe as a heatmap"""
import matplotlib as mpl
import matplotlib.pyplot as plt
def heatmap(df,
edgecolors='w',
cmap=mpl.cm.RdBu,
log=False,vmin=0,vmax=500):
width = len(df.columns)/4
height = len(df.index)/4
# argparse section
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("-l","--list", help="pass a list", nargs="*")
parser.add_argument("-b","--boolean", action="store_true", default=False, help="use this flag to turn on an option")
# grab the options here from the command line, console overrides email
args = parser.parse_args()
@s-boardman
s-boardman / dunn.py
Created February 19, 2016 14:44 — forked from alimuldal/dunn.py
Implementation of Dunn's multiple comparison test, following a Kruskal-Wallis 1-way ANOVA
import numpy as np
from scipy import stats
from itertools import combinations
from statsmodels.stats.multitest import multipletests
from statsmodels.stats.libqsturng import psturng
import warnings
def kw_dunn(groups, to_compare=None, alpha=0.05, method='bonf'):
"""