Understanding the use of any() and all() in numpy arrays
问题 What's the difference between the following: a = np.array([2,3,4]) b = np.array([2,7,8]) if a.any() == b.all(): print('yes') and a = np.array([2,3,4]) b = np.array([2,7,8]) if a.any() == b.any(): print('yes') In both situations, 'yes' is printed. 回答1: any() and all() are intended for boolean arrays. any() returns True if there's any values that are equal to True in the array. all() returns True if all values in the array are equal to True . For integers/floats the functionality is similar,