How can I create a numpy .npy file in place on disk?

后端 未结 2 1753
别跟我提以往
别跟我提以往 2020-12-09 18:47

Is it possible to create an .npy file without allocating the corresponding array in memory first?

I need to create and work with a large numpy array, too big to crea

2条回答
  •  春和景丽
    2020-12-09 19:29

    As you have found out yourself, NumPy is mainly targetted at handling data in memory. There are different libraries for handling data on disk, the one most commonly used today probably being HDF5. I suggest having a look at h5py, an excellent Python wrapper for the HDF5 libraries. It is designed to be used together with NumPy, and its interface is easy to learn if you already know NumPy. To get an impression how it tackles your problem, read the documentation of Datasets.

    For the sake of completeness I should mention PyTables, which seems to be the "standard" way of handling large datasets in Python. I did not use it because h5py appealed more to me. Both libraries have FAQ entries defining their scope against the other one.

提交回复
热议问题