Skip to content

Instantly share code, notes, and snippets.

@philkuz
Created October 14, 2015 19:41
Show Gist options
  • Save philkuz/5bb653edd32321f9fa22 to your computer and use it in GitHub Desktop.
Save philkuz/5bb653edd32321f9fa22 to your computer and use it in GitHub Desktop.
The histogram overlay
#=============EXAMPLE===============
def compare(t, conditions, values):
"""Overlay histograms of values for two conditions."""
t['count'] = 1
e = t.pivot(conditions, values, 'count', sum)
for label in e.column_labels[1:]:
e[label] = e[label]/sum(e[label]) # Normalize each column of counts
e.hist(counts=values, normed=True, overlay=True)
compare(couples, 'mar_status', 'age')
#=============ACTUAL===============
# sample the larger table to the smaller table size
# align
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment