[Numpy] Call savetxt () in append mode

What's this How to execute the function savetxt () that saves ndarray to a file in append mode.

code

savetxt.py


import numpy

a = [[3, 4, 5], [6, 7, 8], [9, 10, 11]]
nda = numpy.array(a)

a2 = [[-3, -4, -5], [-6, -7, -8], [-9, -10, -11]]
nda2 = numpy.array(a2)

with open('output.txt', 'a') as f_handle:
	numpy.savetxt(f_handle, nda)
	numpy.savetxt(f_handle, nda2)

reference

http://stackoverflow.com/questions/17731419/appending-a-matrix-to-an-existing-file-using-numpy http://stackoverflow.com/questions/19793692/strings-and-arraysmatrix-row-wise-numpy-savetxt

Recommended Posts

[Numpy] Call savetxt () in append mode
where in numpy
Axis specification in NumPy
Install numpy in Visual Studio 2019
Imitated Python's Numpy in C #
Matrix multiplication in python numpy
Use Juman ++ in server mode
Accelerate Zhang-Suen algorithm in Numpy
Dynamically call methods in Python
Using Python mode in Processing