pandas dataframe binned data plotting

时间:2015-05-17 22:35:53

标签: python pandas

我有一个pandas数据帧(df),列df.age为0 - 100年,列为df.haircolor(明亮,深色,紫色,灰色)。

现在我想把几十年的年龄结合起来:

bins = np.linspace(df.age.min(), df.age.max(), 10)
decades = df.groupby(np.digitize(df.age, bins))

现在我正试图找到一个很好的方法来绘制这个。我喜欢每个发色都有条形的条纹图案。天真的我试过了。

df['haircolor'].plot(kind='bar', by=decades)

它没有给我我希望的结果。有人有想法吗?感谢。

1 个答案:

答案 0 :(得分:2)

试试这个:

O(n*k)
相关问题