The Python Oracle

Python replace 1.0 and 0.0 with True and False in dataframe

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: Hypnotic Puzzle2

--

Chapters
00:00 Question
00:40 Accepted answer (Score 6)
00:54 Thank you

--

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

--

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

--

Tags
#python #pandas #dataframe #replace

#avk47



ACCEPTED ANSWER

Score 6


Try with bool :-)

df.A=df.A.astype(bool)
df
Out[69]: 
       A
0   True
1  False
2   True
3  False