I am experimenting with the groupby features of pandas, in particular
gb = df.groupby('model')
gb.hist()
Since gb has 50 groups the result is quite cluttered, I would like to explore the result only for the first 5 groups.
I found how to select a single group with groups
or get_group
(How to access pandas groupby dataframe by key), but not how to select multiple groups directly.
The best I could do is :
groups = dict(list(gb))
subgroup = pd.concat(groups.values()[:4])
subgroup.groupby('model').hist()
Is there a more direct way?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…