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

2011-12-22 Thread Chao YUE
O Yes You're right... It's fine now.

Merry Christmas to all!

Chao

2011/12/22 Aronne Merrelli 

>
>
> On Thu, Dec 22, 2011 at 10:27 AM, Chao YUE  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

___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


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

2011-12-22 Thread Aronne Merrelli
On Thu, Dec 22, 2011 at 10:27 AM, Chao YUE  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


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

2011-12-22 Thread Chao YUE
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

___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion