[Numpy-discussion] Numpy save / load

Vishal Rana ranavishal at gmail.com
Mon Jun 21 14:52:07 EDT 2010


Thanks Robert


On Mon, Jun 21, 2010 at 11:47 AM, Robert Kern <robert.kern at gmail.com> wrote:

> On Mon, Jun 21, 2010 at 13:40, Vishal Rana <ranavishal at gmail.com> wrote:
> > I have tried:
> > x1=np.array([1,2,3,4])
> > x2=np.array(['a','dd','xyz','12'])
> > x3=np.array([1.1,2,3,4])
> > r = np.core.records.fromarrays([x1,x2,x3],names='a,b,c'
>
> Note, please do not reach down into numpy.core like this. Use
> numpy.core.records is exposed as numpy.rec.
>
> > type(r) gives <class 'numpy.core.records.recarray'>
> > np.save('np.npy', r)
> > r = np.load('np.npy')
> > type(r) gives  <type 'numpy.ndarray'>
> > So my record is lost and converted to ndarray, any idea?
>
> If you really need a recarray, then use r.view(numpy.rec.recarray).
>
> --
> Robert Kern
>
> "I have come to believe that the whole world is an enigma, a harmless
> enigma that is made terrible by our own mad attempt to interpret it as
> though it had an underlying truth."
>  -- Umberto Eco
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20100621/d0d6f0c4/attachment.html>


More information about the NumPy-Discussion mailing list