Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can we see the group data in pandas.core.groupby.SeriesGroupBy object

Tags:

python

pandas

Can we check the data in a pandas.core.groupby.SeriesGroupBy object?

like image 996
ben Avatar asked Nov 16 '16 11:11

ben


2 Answers

Sure, just use

df.groupby(column).head()

It shows you the first n rows (default: 5).

like image 50
serv-inc Avatar answered Sep 21 '22 06:09

serv-inc


First option: iterate over all groups.

for name, group in df.groupby(column):
    print(name)
    print(group)
    print('\n')

Second option: if you want to see the group for a specific value, use the get_group method.

df.groupby(column).get_group(name)
like image 41
IanS Avatar answered Sep 22 '22 06:09

IanS