Skip to content

Instantly share code, notes, and snippets.

View VictorValverde's full-sized avatar

Víctor Valverde VictorValverde

View GitHub Profile
@waltonjones
waltonjones / Stylable Pandas Groupby Boxplots
Last active March 1, 2016 16:38
This gist includes a function called stylable_groupby_boxplot() that receives a pandas dataframe object and the column you want to groupby and returns a dictionary that includes all the boxplot's parts just like the standard matplotlib boxplot function does.
from numpy.random import rand
import matplotlib.pyplot as plt
import pandas as pd
# 2 columns produces an array of 2 matplotlib.axes.AxesSubplot objects
df2 = pd.DataFrame(rand(10,2), columns=['Col1', 'Col2'] )
df2['X'] = pd.Series(['A','B','A','B','A','B','A','B','A','B'])
#1 column produces a single matplotlib.axes.AxesSubplot object
df1 = pd.DataFrame(rand(10), columns=['Col1'] )