I have read 10-20 different question/answers and cannot find an example like this. I want to select rows out of a numpy array as follows:
test = [ [ [0], np.zeros((250,250)), np.array([0,0]) ],
[ [0], np.zeros((250,250)), np.array([1,1]) ],
[ [1], np.zeros((250,250)), np.array([2,2]) ],
[ [2], np.zeros((250,250)), np.array([2,2]) ],
[ [2], np.zeros((250,250)), np.array([2,2]) ]
]
Now convert the list to an numpy array and print the first column:
nptest = np.array(test)
print (nptest[:,0])
> output is: [[0] [0] [1] [2] [2]]
Now try to select just the row where the first element is = 1
just_1s = nptest[nptest[:,0] == 1]
print (just_1s)
> output is []
I don't understand this output.
In my actual problem set I have 100s of each with an arbitrary number of rows with values of 0-15 in the first column. Using the example data above, the desired result would be three numpy arrays as follows:
just_0s = [[ [0], np.zeros((250,250)), np.array([0,0]) ],
[ [0], np.zeros((250,250)), np.array([1,1]) ]
]
just_1s = [[ [1], np.zeros((250,250)), np.array([2,2]) ]]
just_2s = [[ [2], np.zeros((250,250)), np.array([2,2]) ],
[ [2], np.zeros((250,250)), np.array([2,2]) ]
]