robertevansanders robertevansanders - 3 years ago 210
Python Question

How to get number of groups in a groupby object in pandas?

This would be useful so I know how many unique groups I have to perform calculations on. Thank you.

Suppose groupby object is called


Answer Source

As documented, you can get the number of groups with len(dfgroup).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download