Hello I have the following dataframe.
Group Size
Short Small
Short Small
Moderate Medium
Moderate Small
Tall Large
I want to count the frequency of how many time the same row appears in the dataframe.
Group Size Time
Short Small 2
Moderate Medium 1
Moderate Small 1
Tall Large 1
You can use groupby's size
:
In [11]: df.groupby(["Group", "Size"]).size()
Out[11]:
Group Size
Moderate Medium 1
Small 1
Short Small 2
Tall Large 1
dtype: int64
In [12]: df.groupby(["Group", "Size"]).size().reset_index(name="Time")
Out[12]:
Group Size Time
0 Moderate Medium 1
1 Moderate Small 1
2 Short Small 2
3 Tall Large 1
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments