Tutorial by Examples

A boolean array can be created manually by using dtype=bool when creating the array. Values other than 0, None, False or empty strings are considered True. import numpy as np bool_arr = np.array([1, 0.5, 0, None, 'a', '', True, False], dtype=bool) print(bool_arr) # output: [ True True False ...

Page 1 of 1