I/O with numpy

In this last blog of the series of numpy, we will see how to store numpy arrays in a file and reloading it.
Numpy has certain functions like load, save in different different formats.

With the help of examples, will see how to do this. In documentation you will find many functions but here will discuss very few of them which comes in use commonly.

1. load() and save()

It is used to load and save numpy arrays

2. savez() and load()

It is use to save the multiple numpy arrays in the compressed form. It is saving in the .npz format.

3. loadtxt() and savetxt()

It is used to load txt file and saving the numpy arrays in txt file. It is saved with the extension .out.
All these files will be saved in your current directory.

The above output file is as follows -:

So, there are many other functions to store numpy arrays with different extensions and in a different format. For that you can definitely refer the documentation, generally used functions for loading and saving files are discussed here.

Hope you enjoyed learning numpy with us. Keep learning other stuff related to machine learning and data science. Stay tuned!

Close Menu