numpy.matrix manipulations

Question:

I have a question about numpy.matrix class. How can I perform such basic manipulations with matrices as adding, deleting and replacing rows and columns?

p.s. I apologize for the lame question..

Asked By: Maksim Skurydzin

||

Answers:

Perfectly fine question! Try examining this code:

import scipy
X = scipy.rand(3,3)
Y = scipy.rand(3,3)
print X+Y
print scipy.delete(X, 1, 0)
print scipy.delete(X, 1, 1)
X[1,:] = [1,2,3]
print X

For more, see the numpy/scipy docs here: NumPy/SciPy docs

If you are fluent in Matlab, this page is useful: NumPy for Matlab Users

Answered By: Steve Tjoa
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.