[Numpy-discussion] printing array in tabular form

Sudheer Joseph sudheer.joseph at yahoo.com
Tue May 7 05:14:46 EDT 2013


Dear experts,
            I need to print few arrays in a tabular form for example below array IL has 25 elements, is there an easy way to print this as 5x5 comma separated table? in python

IL=[]
for i in np.arange(1,bno+1):
       IL.append(i)
print(IL)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
in fortran I could do it as below
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
integer matrix(5,5)
       in=0
      do, k=1,5
      do, l=1,5
       in=in+1
      matrix(k,l)=in
      enddo
      enddo
      m=5
      n=5
      do, i=1,m
      write(*,"(5i5)") ( matrix(i,j), j=1,n )
      enddo
      end
 

***************************************************************
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
***************************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20130507/386a8f96/attachment.html>


More information about the NumPy-Discussion mailing list