[Tutor] array manipulations
NTB
ntb1088 at gmail.com
Thu Jun 4 02:48:11 CEST 2009
Hello,
I'm an R user, who just started with numpy. I'm planning on setting up a
large nutrient database. Here's my question:
I'm trying to reshape? or manipulate? the following array:
array [['Food 1', 'Nutrient 1', 0.9],
['Food 1', 'Nutrient 2', 0.2],
['Food 2', 'Nutrient 1', 0.55],
['Food 2', 'Nutrient 2', 0.11]]
into a new array that looks like this:
array [['Food 1', 0.9, 0.2],
['Food 2', 0.55, 0.11]]
or more simply:
array [[0.9, 0.2],
[0.55, 0.11]]
In other words, the data and shape that I need in the first array is the 3rd
column, where the row names are the 1st column and the column names are the
2nd column.
I am thinking that I need to use .flat(), maybe with some kind of list
comprehension? I really don't know, and would really appreciate some help.
Thanks!
-NT
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090603/b3866ea8/attachment.htm>
More information about the Tutor
mailing list