Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

pandas group by count

In [4]: df.groupby(['col1', 'col2']).size().reset_index(name='counts')
Out[4]: 
  col1 col2  counts
0    A    B       4
1    C    D       3
2    E    F       2
3    G    H       1
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #pandas #group #count
ADD COMMENT
Topic
Name
4+2 =