Python Forum
Numpy savetxt, how save number with decimal separator
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Numpy savetxt, how save number with decimal separator
#1
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
[Image: NfRQr9R.jpg]
Reply
#2
Have a look in the docs, as usual:
https://numpy.org/doc/stable/reference/g...py.savetxt
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  coma separator is printed on a new line for some reason tester_V 4 487 Feb-02-2024, 06:06 PM
Last Post: tester_V
  how to save to multiple locations during save cubangt 1 554 Oct-23-2023, 10:16 PM
Last Post: deanhystad
  Printing a raw string with a folder separator at the end, duplicates the separator krulah 5 1,223 Nov-28-2022, 12:41 PM
Last Post: snippsat
  Calculate the Euler Number with more decimal places Pedroski55 10 4,505 Oct-31-2021, 04:45 AM
Last Post: Pedroski55
  numpy.savetxt() mesh01 2 2,061 Jun-26-2021, 01:17 PM
Last Post: mesh01
  Creating table in MySQL db with decimal number issue dangermaus33 7 4,890 Nov-20-2020, 10:40 PM
Last Post: dangermaus33
  Save Numpy Array in Another Numpy Array (not Concatenate!) quest 1 1,855 Nov-06-2020, 01:06 PM
Last Post: quest
  How to add a number to each column separtely in numpy array? Oliver 0 1,493 Jul-02-2020, 02:55 PM
Last Post: Oliver
  How show decimal only for none whole number ? SpongeB0B 6 2,636 Mar-27-2020, 09:15 AM
Last Post: DeaD_EyE
  testing for Decimal w/o importing decimal every time Skaperen 7 4,452 May-06-2019, 10:23 PM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020