简体   繁体   中英

How do I check if np.array exist inside another np.array?

I need to find if the np.array exists in another np.array. I have a np.array that is doubles = [[ 0 3][ 0 11][ 1 1][ 1 13][ 2 2][ 2 6][ 2 8][ 2 12][ 3 0][ 3 3][ 3 7][ 3 11][ 3 14][ 4 4][ 4 10][ 6 2][ 6 6][ 6 8][ 6 12][ 7 3][ 7 7][ 7 11][ 8 2][ 8 6][ 8 8][ 8 12][10 4][10 10][11 0][11 3][11 7][11 11][11 14][12 2][12 6][12 8][12 12][13 1][13 13][14 3][14 11]]

And I have a numpy array that contains result = [7 7] How do I check if the result exists in the doubles?

simply use .tolist() ,

if result in doubles.tolist():
    print ("exists")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM