[Numpy-discussion] Selecting columns of a matrix (original) (raw)

Alan G Isaac aisaac at american.edu
Wed Jun 21 04:48:15 EDT 2006


On Tue, 20 Jun 2006, Keith Goodman apparently wrote:

I have a matrix M and a vector (n by 1 matrix) V. I want to form a new matrix that contains the columns of M for which V > 0. One way to do that in Octave is M(:, find(V > 0)). How is it done in numpy?

M.transpose()[V>0] If you want the columns as columns, you can transpose again.

hth, Alan Isaac



More information about the NumPy-Discussion mailing list