[Numpy-discussion] output different columns of ndarray in different formats

Chao YUE chaoyuejoy at gmail.com
Thu Dec 22 11:27:11 EST 2011


Dear all,

Just a small question, how can I output different columns of ndarray in
different formats,
the manual says, "A single format (%10.5f), a sequence of formats, or a
multi-format string"
but I use

np.savetxt('new.csv',data,fmt=['%i4','%f6.3'])

or

np.savetxt('new.csv',data,fmt=('%i4','%f6.3'))

give strange results.

In [33]: data.shape
Out[33]: (6506, 2)

I want the first column integer and second column float.

cheers,

Chao


-- 
***********************************************************************************
Chao YUE
Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL)
UMR 1572 CEA-CNRS-UVSQ
Batiment 712 - Pe 119
91191 GIF Sur YVETTE Cedex
Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16
************************************************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20111222/dd58e593/attachment.html>


More information about the NumPy-Discussion mailing list