Numpy without isin attribute

I tried using the np.isin () function, but every time I do this, it returns an error to me:

AttributeError: 'module' object has no attribute 'isin' 

that's what I'm doing

 import numpy as np a = np.arange(9).reshape((3,3)) test = np.arange(5) print np.isin(a, test) 

I did not find any information about this problem, I use the latest version of numpy and havent if you have problems with another numpy module, why does it return me this error?

+5
source share
3 answers

Reading the Notes section in docs shows

New in version 1.13.0.

I suspect if you do

 print(np.__version__) 

you will see something less than 1.13.0 .

+6
source

The isin function was added in NumPy 1.13 :

New np.isin feature, improved on in1d .

You are probably using an older version.

+7
source

Following the [source] link in the docs, I found that:

 def isin(element, test_elements, assume_unique=False, invert=False): "..." element = np.asarray(element) return in1d(element, test_elements, assume_unique=assume_unique, invert=invert).reshape(element.shape) 

This does nothing that you can no longer do with in1d .

Contains a file that you can download and use from your own directory. It has an extended unique .

+5
source

Source: https://habr.com/ru/post/1269734/


All Articles