Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Pandas GroupBy and keep Columns

In [20]:
df.groupby(['Name','Type','ID']).count().reset_index()

Out[20]:
    Name   Type  ID  Count
0  Book1  ebook   1      2
1  Book2  paper   2      2
2  Book3  paper   3      1
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Pandas #GroupBy #Columns
ADD COMMENT
Topic
Name
7+6 =