Reputation: 595
This one is similar to my own previous question.
If I perform the following groupby
, I get the count()
of each factor
.
df.groupby("factor")["factor"].count()
Output:
factor
0 2000
1 500
2 1000
3 100
Is there a way to get the % of records belonging to each factor. Expected:
factor
0 55,55
1 13,88
2 27,77
3 2,77
Upvotes: 0
Views: 25
Reputation: 150735
Normalize parameter might help you:
df['factor'].value_counts(normalize=True)
Upvotes: 1