My task:
For the next set of questions, we will be using census data from the United States Census Bureau. Counties are political and geographic subdivi
groupby simply returns a groupby object, you'll have to specify an aggregate function to be used on this object, e.g.
groupby
df.groupby(by='STNAME').aggregate({'COUNTY': 'nunique'}).idxmax()[0]
gives
'Texas'
See the pandas docs here for an introduction to grouping/aggregating.