Albert-Jan Roskam wrote:
I was trying to change the one-dim array into a two-dim array so
I could easily retrieve columns. I now use a pandas DataFrame to do that.

Numpy can do that, if I understand what you want correctly,
but it requires an unintuitive trick.

The trick is to index the array with the name of a field,
and *only* the name of the field. For example, the following
gives you a slice containing all the values from the 'v02'
fields of your data:

  array['v02']

Note: Indexing with a field name generally seems to follow
a different set of rules. Some things that you'd think would
work don't, e.g.

   array[:, 'v02']

fails with a rather confusing error message. Also,

   array[0, 'v02']

doesn't work either, and has to be written

   array[0]['v02']

instead.

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to