for example, I have a numpy array-like
import numpy as np
x=np.array([[1, 1, 0, 0, 1, 0, 0, 0, 0, 0],
[0, 0, 0, 1, 0, 1, 0, 0, 0, 0],
[0, 0, 1, 1, 0, 0, 1, 0, 0, 0],
[0, 1, 0, 1, 0, 0, 0, 0, 1, 0],
[1, 0, 0, 0, 0, 0, 1, 0, 0, 0]])
current output: ind=np.argwhere(x) #the accessed indexes are row-wise is it possible to access in column_wise
required output:
[[0 0]
[4 0]
[0 1]
[3 1]
[2 2]
[1 3]
[2 3]
[3 3]
[0 4]
[1 5]
[2 6]
[4 6]
[3 8]]
CodePudding user response:
You could transpose and swap the columns.
ind = np.argwhere(x.T)[:, [1, 0]]