numpy convert true false to 0 1

Do you want to know the details regarding “numpy convert true false to 0 1”. If yes, you’re in the correct tutorial.

numpy convert true false to 0 1

array([False, False,  True,  True], dtype=bool)
>>> 1*y                      # Method 1
array([0, 0, 1, 1])
>>> y.astype(int)            # Method 2
array([0, 0, 1, 1]) 

Final Thoughts

I hope this article helps you to know about “numpy convert true false to 0 1”. If you have any queries regarding this post please let us know via the comment section. Share this article with your friends and family via social networks.

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coder Diksha. Here, I post about programming to help developers.

Share on:

Leave a Comment