Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

pandas group by to dataframe

In [21]: g1.add_suffix('_Count').reset_index()
Out[21]: 
      Name      City  City_Count  Name_Count
0    Alice   Seattle           1           1
1      Bob   Seattle           2           2
2  Mallory  Portland           2           2
3  Mallory   Seattle           1           1
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #pandas #group #dataframe
ADD COMMENT
Topic
Name
9+8 =