I defined a custom function that uses np.histogram
Also note that histogram groups are computed inside the 'Survived'
groups
def hist(x): h, e = np.histogram(x.dropna(), range=(0, 80)) e = e.astype(int) return pd.Series(h, zip(e[:-1], e[1:])) kw = dict(stacked=True, width=1, rot=45) titanic.groupby('Survived').Age.apply(hist).unstack(0).plot.bar(**kw)
source share