Answers for "count columns and make group by in one query"

7

group by count dataframe

df.groupby(['col1', 'col2']).size().reset_index(name='counts')
Posted by: Guest on February-24-2020
0

sql count matching group by

# To count the number of teachers in each department, including 
# rows where COUNT(t.name) == 0
SELECT d.name,COUNT(t.name) FROM teacher t
RIGHT JOIN dept d ON (t.dept=d.id) GROUP BY d.name;
Posted by: Guest on December-21-2021

Code answers related to "count columns and make group by in one query"

Python Answers by Framework

Browse Popular Code Answers by Language