9951 explained code solutions for 126 technologies


python-numpyHow to save Numpy matrix to text file


import numpy as np

matrix = np.array([[1,2], [3,4], [5,6]])
np.savetxt('/tmp/matrix.txt', matrix)ctrl + c
import numpy as np

load Numpy module for Python

np.array

declare Numpy array (or matrix)

.savetxt

saves specified matrix to text file

/tmp/matrix.txt

path to text file to save matrix to

matrix

matrix to save to text file