[Numpy-discussion] array manupulation

Sudheer Joseph sudheer.joseph at yahoo.com
Sat May 25 20:08:28 EDT 2013


Thank you Brian,
                     I was missing the outer brackets.!!
with best regards,
Sudheer
 
***************************************************************
Sudheer Joseph 
Indian National Centre for Ocean Information Services
Ministry of Earth Sciences, Govt. of India
POST BOX NO: 21, IDA Jeedeemetla P.O.
Via Pragathi Nagar,Kukatpally, Hyderabad; Pin:5000 55
Tel:+91-40-23886047(O),Fax:+91-40-23895011(O),
Tel:+91-40-23044600(R),Tel:+91-40-9440832534(Mobile)
E-mail:sjo.India at gmail.com;sudheer.joseph at yahoo.com
Web- http://oppamthadathil.tripod.com
***************************************************************


----- Original Message -----
> From: Bryan Van de Ven <bryanv at continuum.io>
> To: Discussion of Numerical Python <numpy-discussion at scipy.org>
> Cc: 
> Sent: Saturday, 25 May 2013 11:54 PM
> Subject: Re: [Numpy-discussion] array manupulation
> 
> I'm not sure what you tried, but stack will do what you are seeking:
> 
> In [7]: cc = np.ones((2,10)) * np.arange(1, 11)
> 
> In [8]: cc
> Out[8]: 
> array([[  1.,   2.,   3.,   4.,   5.,   6.,   7.,   8.,   9.,  10.],
>        [  1.,   2.,   3.,   4.,   5.,   6.,   7.,   8.,   9.,  10.]])
> 
> In [9]: np.vstack((np.zeros(10), cc))
> Out[9]: 
> array([[  0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.],
>        [  1.,   2.,   3.,   4.,   5.,   6.,   7.,   8.,   9.,  10.],
>        [  1.,   2.,   3.,   4.,   5.,   6.,   7.,   8.,   9.,  10.]])
> 
> Bryan
> 
> 
> On May 25, 2013, at 7:19 AM, Sudheer Joseph <sudheer.joseph at yahoo.com> 
> wrote:
> 
>>  Dear experts,
>>  I can do below operation in matlab but I wanted to do the same in python 
> numpy array.
>>  I tried np.vstak  and np.concatenate but not getting the desired results. 
> please help. I wanted to add a row of zeros to the beginning of a numpy array. 
> What is  the available quick way. 
>> 
>>>>  cc=[1:10;1:10]
>> 
>>  cc =
>>       1     2     3     4     5     6     7     8     9    10
>>       1     2     3     4     5     6     7     8     9    10
>>>>  cc=[cc(1,:)*0;cc]
>>  cc =
>>       0     0     0     0     0     0     0     0     0     0
>>       1     2     3     4     5     6     7     8     9    10
>>       1     2     3     4     5     6     7     8     9    10
>> 
>>  wit best regards,
>>  Sudheer 
>>  ***************************************************************
>>  Sudheer Joseph 
>>  Indian National Centre for Ocean Information Services
>>  Ministry of Earth Sciences, Govt. of India
>>  POST BOX NO: 21, IDA Jeedeemetla P.O.
>>  Via Pragathi Nagar,Kukatpally, Hyderabad; Pin:5000 55
>>  Tel:+91-40-23886047(O),Fax:+91-40-23895011(O),
>>  Tel:+91-40-23044600(R),Tel:+91-40-9440832534(Mobile)
>>  E-mail:sjo.India at gmail.com;sudheer.joseph at yahoo.com
>>  Web- http://oppamthadathil.tripod.com
>>  ***************************************************************
>>  _______________________________________________
>>  NumPy-Discussion mailing list
>>  NumPy-Discussion at scipy.org
>>  http://mail.scipy.org/mailman/listinfo/numpy-discussion
> 
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
> 



More information about the NumPy-Discussion mailing list