[Tutor] Convert structured 1D array to 2D array

Peter Otten __peter__ at web.de
Sat Feb 27 07:16:00 EST 2016

Ek Esawi wrote:

> The result i am looking for is a 2D array (matrix) instead of 1D array
> of tuples. That's when i read a file using genfromtxt, it generated a 1D
> array of n tuples (like the example shown below); each tuple has one row
> from the original file. The file contains multiple data types and so i
> used genfromtxt to specify data types for each column.
> In another way, i just want to convert a 1D array of tuples to 2D array
> where each tuple is converted multiple columns. Here is an example: the
> output from genfromtxt is
> [(1, 2, 3), (‘a’, b’, ’c’), (‘12/12/2009’, ’2/4/2014’, ‘3/4/200’)]

Can you provide the script (should be tiny) that produces this output?

More information about the Tutor mailing list