按组和阈值的直方图

时间:2016-03-04 04:25:39

标签: python pandas

我有一个大型数据框(约1百万行),我希望通过列和绘图直方图进行分组。但是,当我这样做时,我得到了太多的情节:

df['y'].hist(by=df.type,bins=100,normed=True)

然而,其中一些情节仅包含100个点左右。以下命令为我提供了最常见的类型:

df.groupby('type').size()>100

如何使用上述信息绘制包含至少100个数据点的直方图。

我想要做的是以下伪代码:

idx = df.groupby('type').size()>100
types = sorted(df.type.unique())
types = types[idx]
df2 = df.loc[types%in%df.type,:] #THIS is the main point 
df['y'].hist(by=df.type,bins=100,normed=True)

0 个答案:

没有答案
相关问题