December 2017
Intermediate to advanced
386 pages
10h 42m
English
To store a single NumPy array to the disk in text format, use the savetxt() function. In the next example, we generate a large array and save it to the disk in text format using the following code:
x = np.random.rand(200, 300)np.savetxt('array_x.txt', x)
This code first uses the np.random.rand() function to generate a 200 x 300 array of random floats. Next, the savetxt() NumPy function creates the array_x.txt file on the disk, containing a text representation of the x array. The file can be opened with a text editor.
Read now
Unlock full access