Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

create a colun in pandas using groupby

In [13]: df.groupby(["item", "color"])["id"].transform("count")
Out[13]:
0    2
1    2
2    2
3    1
4    2
dtype: int64
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #create #colun #pandas #groupby
ADD COMMENT
Topic
Name
7+9 =