471,318 Members | 1,881 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,318 software developers and data experts.

setting and getting column in numpymatrix

hi
i am looking for an efficient way to get a specific column of a
numpy.matrix ..
also i want to set a column of the matrix with a given set of
values ..i couldn't find any methods for this in matrix doc..do i have
to write the functions from scratch?

TIA
dn

Nov 1 '07 #1
1 1224
de****@gmail.com wrote:
hi
i am looking for an efficient way to get a specific column of a
numpy.matrix ..
also i want to set a column of the matrix with a given set of
values ..i couldn't find any methods for this in matrix doc..do i have
to write the functions from scratch?

TIA
dn
>>from numpy import matrix
x=matrix([[1,2,3],[4,5,6],[7,8,9]])
x[:,1]
matrix([[2],
[5],
[8]])
>>x[:,1].transpose()
matrix([[2, 5, 8]])
>>matrix([11,12,13]).transpose()
matrix([[11],
[12],
[13]])
>>x[:,1] = matrix([11,12,13]).transpose()
x
matrix([[ 1, 11, 3],
[ 4, 12, 6],
[ 7, 13, 9]])
Nov 1 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Chris | last post: by
2 posts views Thread by Sagaert Johan | last post: by
4 posts views Thread by Chuck | last post: by
3 posts views Thread by Annette Block | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.