syntax.us Let the syntax do the talking
Blog Contact Posts Questions Tags Hire Me

Question:
In Python NumPy how do I write Array to CSV?

When I work with Python NumPy, I often encounter use-cases which require that I write a NumPy Array to a CSV file.

The syntax below demonstrates creation of a simple Array and then writing it to a CSV file:
import numpy as np
col0 = [1.1, 2.2, 3.3]
col1 = [11.1, 22.2, 33.3]
myarray = np.array([col0, col1])
np.savetxt('/tmp/myarray.csv', myarray, delimiter=',', fmt=('%4.3f'))



syntax.us Let the syntax do the talking
Blog Contact Posts Questions Tags Hire Me