python读取npy文件_python – 如何在磁盘上创建一个numpy .npy文件?

当我读到Sven的回复时,我也有同样的问题,感到失望.似乎numpy将错过一些关键的功能,如果你不能有一个巨大的数组文件,并在一小块工作一次.您的案例似乎接近使用.npy格式的原始理性的一个用例(参见:

http://svn.scipy.org/svn/numpy/trunk/doc/neps/npy-format.txt).

然后我碰到了numpy.lib.format,这似乎是有用的好东西.我不知道为什么这个功能是不可用的numpy根包.与HDF5相比,它的主要优点在于它带有麻烦.

>>> print numpy.lib.format.open_memmap.__doc__

"""

Open a .npy file as a memory-mapped array.

This may be used to read an existing file or create a new one.

Parameters

----------

filename : str

The name of the file on disk. This may not be a filelike object.

mode : str, optional

The mode to open the file with. In addition to the standard file modes,

'c' is also accepted to mean "copy on write". See `numpy.memmap` for

the available mode strings.

dtype : dtype, optional

The data type of the array if we are creating a new file in "write"

mode.

shape : tuple of int, optional

The shape of the array if we are creating a new file in "write"

mode.

fortran_order : bool, optional

Whether the array should be Fortran-contiguous (True) or

C-contiguous (False) if we are creating a new file in "write" mode.

version : tuple of int (major, minor)

If the mode is a "write" mode, then this is the version of the file

format used to create the file.

Returns

-------

marray : numpy.memmap

The memory-mapped array.

Raises

------

ValueError

If the data or the mode is invalid.

IOError

If the file is not found or cannot be opened correctly.

See Also

--------

numpy.memmap

"""

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值