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

后端 未结 6 2315
星月不相逢
星月不相逢 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:08

    I think the closest you'll get is numpy.ismember1d, but it won't work well with your example. I think your solution (B = (A==v[0]) + (A==v[1])) may actually be the best one.

提交回复
热议问题