[SciPy-user] help on array manipulation

Tim Michelsen timmichelsen@gmx-topmail...
Tue Nov 20 10:47:21 CST 2007


Hello,

I have the following array:

In [240]: z
Out[240]:
array([[ 15.,   3.,   7.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,
          0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,
          0.,   0.,   0.],
       [ 16.,   3.,   7.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,
          0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,
          0.,   0.,   0.],
       [ 17.,   3.,   7.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,
          0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,
          0.,   0.,   0.]])

How do I get it be become like:

15 3
15 7
15 0
...
16 3
16 7
...
17 3


Is there a special function I can use for this or do I need to build various for
loops to achive this?

I mean this example has few data. But what if the amount increases?

I am stuck here.

I'd be very glad if anyone could point be to a good tutorial for array
manipulation. Scipy Cookbook is not enough.
Well, I also found :
http://numpy.scipy.org/numpydoc
and
http://www.penzilla.net/tutorials/python/numeric

Thanks in advance,
Timmie


###
# Code for the array:

###
z = numpy.zeros((3,25))
z = numpy.zeros((3,25))
for i in xrange(z.shape[1]):
    z[:,0] = 1
    z[:,1] = 3
    z[:,2] = 7
    

for i in xrange(z.shape[0]):
    z[0,0] = 15
    z[1,0] = 16
    z[2,0] = 17



More information about the SciPy-user mailing list