Reputation: 85
Does anyone understand what I am doing wrong with the numpy intersect1d function ?
import numpy as np
x = np.array([1, 1, 2, 3, 4])
y = np.array([2, 1, 4, 6])
xy, x_ind, y_ind = np.intersect1d(x, y, return_indices=True)
and I get this output error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: intersect1d() got an unexpected keyword argument 'return_indices'
I am using Python 3.6
Thanks
Upvotes: 0
Views: 1332
Reputation: 738
It is not a problem with your Python version but the Numpy version. I executed your code with a perfectly reasonable result i.e. it did not generate the error.
import numpy as np
x = np.array([1, 1, 2, 3, 4])
y = np.array([2, 1, 4, 6])
xy, x_ind, y_ind = np.intersect1d(x, y, return_indices=True)
print(xy)
print(x_ind)
print(y_ind)
>>
[1 2 4]
[0 2 4]
[1 0 2]
Upvotes: 1