Building a huge numpy array using pytables

后端 未结 2 1709
情深已故
情深已故 2020-12-28 23:53

How can I create a huge numpy array using pytables. I tried this but gives me the \"ValueError: array is too big.\" error:

import numpy as np
import tables a         


        
2条回答
  •  误落风尘
    2020-12-29 00:08

    You could try to use tables.CArray class as it supports compression but...

    I think questions is more about numpy than pytables because you are creating array using numpy before storing it with pytables.

    In that way you need a lot of ram to execute np.zeros((ndim,ndim) - and this is probably the place where exception: "ValueError: array is too big." is raised.

    If matrix/array is not dense then you could use sparse matrix representation available in scipy: http://docs.scipy.org/doc/scipy/reference/sparse.html

    Another solution is to try to access your array via chunks if it you don't need whole array at once - check out this thread: Very large matrices using Python and NumPy

提交回复
热议问题