In [38]: x = np.arange(1,10).reshape(3,3) In [40]: print(np.array2string(x, separator=', ')) [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
To save a NumPy x array to a file:
np.set_printoptions(threshold=np.inf, linewidth=np.inf) # turn off summarization, line-wrapping with open(path, 'w') as f: f.write(np.array2string(x, separator=', '))
unutbu
source share