The Python Oracle

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

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: Quirky Dreamscape Looping

--

Chapters
00:00 Question
00:46 Accepted answer (Score 8)
00:58 Answer 2 (Score 5)
01:12 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)