Numpy arrays have an astype
method. Just do y.astype(int)
.
Note that it might not even be necessary to do this, depending on what you're using the array for. Bool will be autopromoted to int in many cases, so you can add it to int arrays without having to explicitly convert it:
>>> x
array([ True, False, True], dtype=bool)
>>> x + [1, 2, 3]
array([2, 2, 4])