Python Forum
comparing each rows of two matrix
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
comparing each rows of two matrix
#6
(Apr-18-2019, 12:19 PM)DeaD_EyE Wrote: Use itertools.product, to avoid nested loops:
[x for x,y in itertools.product(a,b) if np.array_equal(x,y)]

This is very good point.

To get answer OP looking for:

>>> sum(1 for x, y in product(a, b) if np.array_equal(x, y))
5
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Messages In This Thread
comparing each rows of two matrix - by PhysChem - Apr-18-2019, 06:17 AM
RE: comparing each rows of two matrix - by PhysChem - Apr-18-2019, 12:03 PM
RE: comparing each rows of two matrix - by DeaD_EyE - Apr-18-2019, 12:19 PM
RE: comparing each rows of two matrix - by perfringo - Apr-18-2019, 12:54 PM
RE: comparing each rows of two matrix - by PhysChem - Apr-21-2019, 03:13 PM
RE: comparing each rows of two matrix - by PhysChem - May-14-2019, 09:22 AM
RE: comparing each rows of two matrix - by PhysChem - May-16-2019, 09:47 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020