[Numpy-discussion] intersect1d and setmember1d
mudit sharma
mudit_19a@yahoo....
Thu Feb 26 11:48:52 CST 2009
intersect1d and setmember1d doesn't give expected results in case there are duplicate values in either array becuase it works by sorting data and substracting previous value. Is there an alternative in numpy to get indices of intersected values.
In [31]: p nonzero(setmember1d(v1.Id, v2.Id))[0]
[ 0 1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 <-------------- index 2 shouldn't be here look at the data below.
26 27 28 29]
In [32]: p v1.Id[:10]
[ 232. 232. 233. 233. 234. 234. 235. 235. 237. 237.]
In [33]: p v2.Id[:10]
[ 232. 232. 234. 234. 235. 235. 236. 236. 237. 237.]
In [34]: p setmember1d(v1.Id, v2.Id)
[ True True True False True True True True True True True True <-------------- index 2 shouldn't be True
True True True True True True True True True True True True
True True True True True True]
In [35]: p setmember1d(v1.Id[:10], v2.Id[:10])
[ True True True False True True True True True True]
More information about the Numpy-discussion
mailing list