logo       

Re: Reshaping along an axis: msg#00009

python.numeric.general

Subject: Re: Reshaping along an axis

Karthikesh Raju wrote:

Hi all,

Suppose i have a tuple or a 1D array as

a = (1,2,3,4,5,6,7,8,9)

presently reshape(a,(3,3)) gives me

1 2 3
4 5 6
7 8 9

i.e reshaping is done column wise. How do one specifiy reshape to work row
wise as: reshape(a,(3,3)) =
1 4 7
2 5 8
3 6 9


Use transpose pluse reshape:

>>> a = (1,2,3,4,5,6,7,8,9)
>>> print transpose(reshape(a, (3,3)))
[[1 4 7]
[2 5 8]
[3 6 9]]

-tim


With warm regards

karthik


-----------------------------------------------------------------------
Karthikesh Raju, email: karthik@xxxxxxxxxxxx
karthikesh.raju@xxxxxxxxx
Researcher, http://www.cis.hut.fi/karthik
Helsinki University of Technology, Tel: +358-9-451 5389
Laboratory of Comp. & Info. Sc., Fax: +358-9-451 3277
Department of Computer Sc.,
P.O Box 5400, FIN 02015 HUT,
Espoo, FINLAND
-----------------------------------------------------------------------


-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/numpy-discussion






-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise