[Numpy-discussion] Fortran order in recarray.

Alex Rogozhnikov alex.rogozhnikov at yandex.ru
Tue Feb 21 18:24:39 EST 2017

```Ah, got it. Thanks, Chris!
I thought recarray can be only one-dimensional (like tables with named columns).

Maybe it's better to ask directly what I was looking for:
something that works like a table with named columns (but no labelling for rows), and keeps data (of different dtypes) in a column-by-column way (and this is numpy, not pandas).

Is there such a magic thing?

Alex.

> 22 февр. 2017 г., в 2:10, Chris Barker <chris.barker at noaa.gov> написал(а):
>
>
>
> On Tue, Feb 21, 2017 at 3:05 PM, Alex Rogozhnikov <alex.rogozhnikov at yandex.ru <mailto:alex.rogozhnikov at yandex.ru>> wrote:
> a question about numpy.recarray:
> There is a parameter order in constructor https://docs.scipy.org/doc/numpy-1.10.1/reference/generated/numpy.recarray.html <https://docs.scipy.org/doc/numpy-1.10.1/reference/generated/numpy.recarray.html>, but it seems to have no effect:
> x = numpy.recarray(dtype=[('a', int), ('b', float)], shape=[1000], order='C')
>
> you are creating a 1D array here -- there is no difference between Fortran and C order for a 1D array. For 2D:
>
> In [2]: x = numpy.recarray(dtype=[('a', int), ('b', float)], shape=[10,10], order='C')
>
>
> In [3]: x.strides
> Out[3]: (160, 16)
>
>
> In [4]: y = numpy.recarray(dtype=[('a', int), ('b', float)], shape=[10,10], order='F')
>
>
> In [5]: y.strides
> Out[5]: (16, 160)
>
> note the easier way to get the strides, too :-)
>
> -CHB
>
>
>
> --
>
> Christopher Barker, Ph.D.
> Oceanographer
>
> Emergency Response Division
> NOAA/NOS/OR&R            (206) 526-6959   voice
> 7600 Sand Point Way NE   (206) 526-6329   fax
> Seattle, WA  98115       (206) 526-6317   main reception
>
> Chris.Barker at noaa.gov <mailto:Chris.Barker at noaa.gov>_______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> https://mail.scipy.org/mailman/listinfo/numpy-discussion

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20170222/61947b5b/attachment.html>
```

More information about the NumPy-Discussion mailing list