You can use one of the following two approaches to convert True/False to 1/0.
1. Using astype(int)
>>> import numpy as np>>> a=np.array([[True, False, False],[False,False,True]])>>> aarray([[ True, False, False], [False, False, True]])>>> a.astype(int)array([[1, 0, 0], [0, 0, 1]])
2. Simply multiply your matrix by 1:
>>> import numpy as np>>> a=np.array([[True, False, False],[False,False,True]])>>> aarray([[ True, False, False], [False, False, True]])>>> a*1array([[1, 0, 0], [0, 0, 1]])