The Python Oracle

Panda Python - Calculating what percentage of values are true and false out of total in boolean column

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: RPG Blues Looping

--

Chapters
00:00 Panda Python - Calculating What Percentage Of Values Are True And False Out Of Total In Boolean Colu
00:27 Answer 1 Score 5
00:37 Accepted Answer Score 9
00:44 Thank you

--

Full question
https://stackoverflow.com/questions/5222...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #pandas

#avk47



ACCEPTED ANSWER

Score 9


You can do with

df['yourcolumns'].value_counts(normalize=True).mul(100).astype(str)+'%'



ANSWER 2

Score 5


I was notified that it is as simple as

df['column'].value_counts(normalize=True)