Reputation: 169
Hello I have a boolean value with True and False.
When I run a value_counts()
like this
df['column'].value_counts()
I receive the following:
True 10718
False 1105
Name: column, dtype: int64
Is there a way to calculate what % of the total is true and what % is false?
Something like this:
True 91%
False 09%
Name: column, dtype: int64
Thank you
Upvotes: 6
Views: 10220
Reputation: 323316
You can do with
df['yourcolumns'].value_counts(normalize=True).mul(100).astype(str)+'%'
Upvotes: 9
Reputation: 169
I was notified that it is as simple as
df['column'].value_counts(normalize=True)
Upvotes: 5