output different columns of ndarray in different formats
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 ************************************************************************************
On Thu, Dec 22, 2011 at 10:27 AM, Chao YUE <chaoyuejoy@gmail.com> wrote:
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.
I think you've flipped the format codes; try: fmt = ('%4i', '%6.3f')
O.... Yes.... You're right... It's fine now. Merry Christmas to all! Chao 2011/12/22 Aronne Merrelli <aronne.merrelli@gmail.com>
On Thu, Dec 22, 2011 at 10:27 AM, Chao YUE <chaoyuejoy@gmail.com> wrote:
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.
I think you've flipped the format codes; try:
fmt = ('%4i', '%6.3f')
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
-- *********************************************************************************** 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 ************************************************************************************
participants (2)
-
Aronne Merrelli -
Chao YUE