How can I map True/False to 1/0 in a Pandas DataFrame?
True
is 1
in Python, and likewise False
is 0
*:
>>> True == 1True>>> False == 0True
You should be able to perform any operations you want on them by just treating them as though they were numbers, as they are numbers:
>>> issubclass(bool, int)True>>> True * 55
So to answer your question, no work necessary - you already have what you are looking for.
* Note I use is as an English word, not the Python keyword is
- True
will not be the same object as any random 1
.