0

I have a data frame which contains consumption data for the various building. The buildings are divided into few categories, further divided into subcategories. How could I return the count of the number of buildings of every subcategory itself?

1 Answers1

1

Suppose you have two columns, called col_1 and col_2. Then you can group by on the two of them by doing

df.groupby(['col_1','col_2']).count()

This would return the count for all the other columns in the database in the hierarchy specified by the columns col_1 and col_2