Python Forum
Numpy savetxt, how save number with decimal separator - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Numpy savetxt, how save number with decimal separator (/thread-26701.html)



Numpy savetxt, how save number with decimal separator - SpongeB0B - May-10-2020

I generated a Array with
x = numpy.zeros((2,2))
and assigned one "index" with a value =
x[0,1] = 5.25
I would like to export easily this as an CSV. I used
numpy.savetxt('exported.csv',x.ravel(),delimiter=',')
But this store the data as float:
5.349999999999999645e+00

How could I have the data formatted as such ?

Quote:0
5.25
0



RE: Numpy savetxt, how save number with decimal separator - ThomasL - May-10-2020

Have a look in the docs, as usual:
https://numpy.org/doc/stable/reference/generated/numpy.savetxt.html?highlight=savetxt#numpy.savetxt


This forum uses Lukasz Tkacz MyBB addons.
Forum use Krzysztof "Supryk" Supryczynski addons.