-3

I am running a Python code and need to save the data in csv format. However, just can't success. I write the code or save the data as below:

np.save('clear-m.csv', [SEn_thg, bta_thg])
np.save('blur-m.csv', [SEn_3ph, bta_3ph])

but what I get is still an NPY file instead of a csv file as below:

clear-m.csv.npy
blur-m.csv.npy

Please suggest me how to do that right?

Daniel L
  • 31
  • 6
  • 1
    Does this answer your question? [How to save numpy ndarray as .csv file?](https://stackoverflow.com/questions/48622281/how-to-save-numpy-ndarray-as-csv-file) Please read [ask] and [what's on-topic](/help/on-topic), and the [question checklist](//meta.stackoverflow.com/q/260648/843953). [Asking on Stack Overflow is not a substitute for doing your own research.](//meta.stackoverflow.com/a/261593/843953) – Pranav Hosangadi Nov 23 '20 at 19:41

1 Answers1

1

Try savetxt() method:

np.savetxt("clear-m.csv", [SEn_thg, bta_thg], delimiter=",")
Alexandra Dudkina
  • 4,302
  • 3
  • 15
  • 27
  • Questions that can be answered with a simple google search have usually already been asked and answered on Stack Overflow. In such cases, it's better to flag / vote to close this question as a duplicate instead of adding your own answer. – Pranav Hosangadi Nov 23 '20 at 19:44