I want to judge the authenticity of the elements of numpy array

Thing you want to do

There are two numpy arrays, a and b. I want to know if the element of b is included in a ...

It seems that this can be done for the time being

example.py


import numpy as np

a = np.array([[1,2,3],[2,3,4],[4,5,6]])
b = np.array([4,5,6])

(a==b).all(axis=1).any()

Result ↓

True

Function used

all function

A function that returns True when all elements are true

【argument】 ・ Axis Specifying 0 returns the result in the row direction, and specifying 1 returns the result in the column direction.

any function

A function that returns True when any element is true

Recommended Posts

I want to judge the authenticity of the elements of numpy array
I want to align the significant figures in the Numpy array
I want to customize the appearance of zabbix
I want to grep the execution result of strace
I want to fully understand the basics of Bokeh
Convert elements of numpy array from float to int
I want to increase the security of ssh connections
Set the number of elements in a NumPy one-dimensional array to a power of 2 (0 padded)
I want to use only the normalization process of SudachiPy
I want to get the operation information of yahoo route
I want to change the Japanese flag to the Palau flag with Numpy
I want to know the features of Python and pip
Keras I want to get the output of any layer !!
I want to know the legend of the IT technology world
I want to get the name of the function / method being executed
I want to manually assign the training parameters of the [Pytorch] model
I want to read the html version of "OpenCV-Python Tutorials" OpenCV 3.1 version
numpy: I want to convert a single type ndarray to a structured array
I want to output the beginning of the next month with Python
I want to check the position of my face with OpenCV!
I want to know the population of each country in the world.
I want to pin Spyder to the taskbar
I want to output to the console coolly
I want to handle the rhyme part1
I want to handle the rhyme part3
I want to display the progress bar
I want to handle the rhyme part2
I want to handle the rhyme part5
I want to handle the rhyme part4
[Note] I want to completely preprocess the data of the Titanic issue-Age version-
I don't want to admit it ... The dynamical representation of Neural Networks
(Python Selenium) I want to check the settings of the download destination of WebDriver
I want to batch convert the result of "string" .split () in Python
I want to explain the abstract class (ABCmeta) of Python in detail.
I want to sort a list in the order of other lists
I want to express my feelings with the lyrics of Mr. Children
I want to analyze the emotions of people who want to meet and tremble
I want to use the Qore SDK to predict the success of NBA players
I want to leave an arbitrary command in the command history of Shell
I want to stop the automatic deletion of the tmp area with RHEL7
Python: I want to measure the processing time of a function neatly
I made a function to see the movement of a two-dimensional array (Python)
Sort the elements of the array by specifying the conditions
I want to handle the rhyme part7 (BOW)
I tried to touch the API of ebay
I tried to correct the keystone of the image
The shape of the one-dimensional array of numpy was complicated
I want to get League of Legends data ③
I want to get League of Legends data ②
I checked the processing speed of numpy one-dimensionalization
[Python numpy] Dynamically specify the index of the array
I want to get League of Legends data ①
I want to use the activation function Mish
I want to display the progress in Python!
I tried to predict the price of ETF
I tried to vectorize the lyrics of Hinatazaka46!
I want to visualize the transfer status of the 2020 J League, what should I do?
The story of IPv6 address that I want to keep at a minimum
I want to use Python in the environment of pyenv + pipenv on Windows 10
I want to use PyTorch to generate something like the lyrics of Japari Park
Save an array of numpy to a wav file using the wave module