[Numpy-discussion] printing array in tabular form

Sudheer Joseph sudheer.joseph at yahoo.com
Sat May 11 03:53:45 EDT 2013


Thank you very much,
                      These tips with some effort from me should do it for me.
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: Henry Gomersall <heng at cantab.net>
> To: Discussion of Numerical Python <numpy-discussion at scipy.org>
> Cc: 
> Sent: Friday, 10 May 2013 5:29 PM
> Subject: Re: [Numpy-discussion] printing array in tabular form
> 
> On Fri, 2013-05-10 at 17:14 +0800, Sudheer Joseph wrote:
>>  Thank you,
>>                But I was looking for  a format statement likw
>>  write(*,"(A,5F8.3)")
>>  with best regards,
>>  Sudheer
> 
> How about the following:
> 
> print('IL = ' + (('%d,' * 5)[:-1] + '\n     ') * 5 % 
> tuple(IL))
> 
> If instead of a list IL you had some arbitrary 2D array, a, you could do
> (with 2 lines for clarity):
> 
> print_string = 'a  = ' + (('%d,' * a.shape[1])[:-1] + 
> '\n     ') *
>                           a.shape[0] % tuple(a.T.ravel())
> print(print_string)
> 
> I'll leave it as an exercise for you to put that into a file.
> 
> hen
> 
> _______________________________________________
> 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