[Numpy-discussion] PEP: named axis
Robert Kern
robert.kern@gmail....
Fri Feb 6 15:02:32 CST 2009
On Fri, Feb 6, 2009 at 09:31, Bruce Southey <bsouthey@gmail.com> wrote:
> Hi,
> +1 on the idea but how will this work with other numpy methods?
>
> suppose *arr* is a structured array with dtype:
>
> [('name', 'S25'),
> ('height', float),
> ('age', int),
> ('gender', 'S8')
> ]
>
>
> Would you be able to first define a list of columns such as
> cols=['height', 'age']
> arr[cols]
> This would be a handy feature.
Yes. ndarray.__getitem__() doesn't know anything about where the list
of strings comes from.
> For example, for some compatible array A, would you be able to the
> following with a view
>
> np.linalg.lstsq(A, arr[['age']])
> np.linalg.lstsq(A,arr[['height', 'age']]
No, you'd still get a record array, which lstsq() doesn't know what to do with.
--
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
More information about the Numpy-discussion
mailing list