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?
Asked
Active
Viewed 1,540 times
1 Answers
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

Quantum_Something
- 116
- 1
- 6