How can I implement matlabs ``ismember()`` command in Python?

后端 未结 6 2310
星月不相逢
星月不相逢 2020-12-19 22:59

here is my problem: I would like to create a boolean matrix B that contains True everywhere that matrix A has a value contained in vector v. One inconvenient so

6条回答
  •  长情又很酷
    2020-12-19 23:09

    Since Numpy version 1.4 there's a new function, in1d() that's the equivalent of ismember() in matlab: http://docs.scipy.org/doc/numpy-1.6.0/reference/generated/numpy.in1d.html. But as ars points out, it only returns a 1d array.

提交回复
热议问题