I have a matrix a which I create like this:
>>> a = np.matrix("1 2 3; 4 5 6; 7 8 9; 10 11 12")
I have a matrix labels which I create like this:
>>> labels = np.matrix("1;0;1;1")
This is what the two matricies look like:
>>> a
matrix([[ 1, 2, 3],[ 4, 5, 6],[ 7, 8, 9],[10, 11, 12]])
>>> labels
matrix([[1],[0],[1],[1]])
As you can see, when I select all columns, there is no problem
>>> a[labels == 1, :]
matrix([[ 1, 7, 10]])
But when I try to specify a column I get an error
>>> a[labels == 1, 1]
Traceback (most recent call last):File "<stdin>", line 1, in <module>File "/usr/local/lib/python2.7/site-packages/numpy/matrixlib/defmatrix.py", line 305, in __getitem__out = N.ndarray.__getitem__(self, index)
IndexError: too many indices for array
>>>
Does anybody know why this is? I am aware there are similar questions to this already but none of them explain my problem well enough, neither are the answers helpful to me.