numpy.intersect1d
本帖最后由 shaoheshaohe 于 2019-1-2 11:13 编辑numpy.intersect1d(ar1, ar2, assume_unique=False)Find the intersection of two arrays.
Return the sorted, unique values that are in both of the input arrays.
Parameters:ar1, ar2 : array_likeInput arrays.
assume_unique : bool
If True, the input arrays are both assumed to be unique, whichcan speed up the calculation.Default is False.
Returns:intersect1d : ndarraySorted 1D array of common and unique elements.
See alsonumpy.lib.arraysetops
Module with a number of other functions for performing set operations on arrays.
Examples>>>>>> np.intersect1d(, )
array()
To intersect more than two arrays, use functools.reduce:
>>>>>> from functools import reduce
>>> reduce(np.intersect1d, (, , ))
array()
这就是求交集
的方法
用起来很方便
就是一个问题
需要求多个集合的交集,怎么干呢?
页:
[1]