0

I want to apply the NOT operation on whole columns/rows of a boolean Numpy array. Is this possible with Numpy?

matrix = np.array([[False for i in range(3)] for j in range(2)])
# Initial
# [False, False, False]
# [False, False, False]

matrix[:,1].not() # Something like this
# After not operation on column 1
# [False, True, False]
# [False, True, False]
Muddassir Ahmed
  • 518
  • 4
  • 19
  • Google led me to https://stackoverflow.com/questions/13728708/inverting-a-numpy-boolean-array-using –  Aug 19 '20 at 15:07

1 Answers1

1

This should do the trick, see here

matrix[:, 1] = np.logical_not(matrix[:, 1])
cmplx96
  • 1,541
  • 8
  • 34
  • 48