Comparing two numpy arrays and removing elements

前端 未结 3 1861
日久生厌
日久生厌 2020-12-22 04:08

I have been going through several solutions, but I am not able to find a solution I need.

I have two numpy arrays. Let\'s take a small example<

3条回答
  •  自闭症患者
    2020-12-22 05:02

    You can use built-in sets:

    final_x = set(x) - set(y)
    

    and subtract the second from the first. You can convert final_x to a list or numpy.array if you feel so inclined.

提交回复
热议问题