[Numpy-discussion] bitwise or'ing rows

Mads Ipsen mads.ipsen at gmail.com
Tue Apr 4 03:14:07 EDT 2017


Hi

If I have an n x m array of bools, is there a handy way for me to 
perform a 'bitwise_and' or 'bitwise_or' along an axis, for example all 
the rows or all the columns? For example

a =
[[1,0,0,0],
  [0,0,1,0],
  [0,0,0,0]] (0 and 1 meaning True and False)

a.bitwise_or(axis=0)

giving

[1,0,1,0]

Best regards,

Mads




-- 
+---------------------------------------------------------------------+
| Mads Ipsen                                                          |
+----------------------------------+----------------------------------+
| Overgaden Oven Vandet 106, 4.tv  | phone:              +45-29716388 |
| DK-1415 København K              | email:      mads.ipsen at gmail.com |
| Denmark                          | map  : https://goo.gl/maps/oQ6y6 |
+----------------------------------+----------------------------------+


More information about the NumPy-Discussion mailing list