Write a NumPy program to check whether a Numpy array contains a specified row.
import numpy as np num = np.arange(20) arr1 = np.reshape(num, [4, 5]) print("Original array:") print(arr1) print([0, 1, 2, 3, 4] in arr1.tolist()) print([0, 1, 2, 3, 5] in arr1.tolist()) print([15, 16, 17, 18, 19] in arr1.tolist())
Sample Output:
Original array: [[ 0 1 2 3 4] [ 5 6 7 8 9] [10 11 12 13 14] [15 16 17 18 19]] True False True
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer