array manipulation-

A

Aram Ter-Sarkissov

hi, this is probably a very silly question, but I can't get my hear
around it unfortunately(

I have an array (say, mat=rand(3,5)) from which I 'pull out' a row
(say, s1=mat[1,]). The problem is, the shape of this row s1 is not
[1,5], as I would expect, but rather [5,], which means that I can't,
for example, concateante mat and s1 rowwise.

thanks for the help
 
R

Robert Kern

hi, this is probably a very silly question, but I can't get my hear
around it unfortunately(

I have an array (say, mat=rand(3,5)) from which I 'pull out' a row
(say, s1=mat[1,]). The problem is, the shape of this row s1 is not
[1,5], as I would expect, but rather [5,], which means that I can't,
for example, concateante mat and s1 rowwise.

thanks for the help

You can ask numpy questions on the numpy mailing list.

http://www.scipy.org/Mailing_Lists

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
 
G

Gregory Ewing

Aram said:
I have an array (say, mat=rand(3,5)) from which I 'pull out' a row
(say, s1=mat[1,]). The problem is, the shape of this row s1 is not
[1,5], as I would expect, but rather [5,], which means that I can't,
for example, concateante mat and s1 rowwise.

Use a 2D slice:
>>> a = array([[1,2],[3,4]])
>>> a
array([[1, 2],
[3, 4]])
array([[3, 4]])
(1, 2)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top