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

2016-02-28 Thread Oscar Benjamin
On 26 February 2016 at 16:46, Ek Esawi wrote: > > I used genfromtxt to read a file with multiple data types. The result was a > 1D array of tuples; for example > > [(1, 2, 3), (‘a’, b’, ’c’), (‘12/12/2009’, ’2/4/2014’, ‘3/4/200)’] > > > > I am trying to convert this structured array to a 2D array.

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

2016-02-27 Thread Ek Esawi
Thanks Peter. It works now. I am trying to be creative but i am still getting my way around pythony. EKE ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

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

2016-02-27 Thread Emile van Sebille
On 2/26/2016 7:26 PM, 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

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

2016-02-27 Thread Peter Otten
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 t

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

2016-02-27 Thread Ek Esawi
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 genfro

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

2016-02-27 Thread Peter Otten
Peter Otten wrote: > Or try > > b = numpy.array(a, dtype=(object, object)) That won't work, I accidentally tested it on an already converted array :( ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.p

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

2016-02-27 Thread Peter Otten
Ek Esawi wrote: > Thanks for the input. I tried your idea but i did not work; l got 1D array > of tuples; the same as the original array. I think b/c genfromtxt creates > an array and so it's already an array object-if i understand it correctly. > Your idea works well for a list which i tested but

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

2016-02-26 Thread Danny Yoo
On Feb 26, 2016 9:29 AM, "Ek Esawi" wrote: > > Hi All— > > > > I used genfromtxt to read a file with multiple data types. The result was a > 1D array of tuples; for example > > [(1, 2, 3), (‘a’, b’, ’c’), (‘12/12/2009’, ’2/4/2014’, ‘3/4/200)’] > > > > I am trying to convert this structured array t

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

2016-02-26 Thread Ek Esawi
Thanks for the input. I tried your idea but i did not work; l got 1D array of tuples; the same as the original array. I think b/c genfromtxt creates an array and so it's already an array object-if i understand it correctly. Your idea works well for a list which i tested but i want to an n x n 2D ar

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

2016-02-26 Thread Peter Otten
Ek Esawi wrote: > I used genfromtxt to read a file with multiple data types. The result was > a 1D array of tuples; for example > > [(1, 2, 3), (‘a’, b’, ’c’), (‘12/12/2009’, ’2/4/2014’, ‘3/4/200)’] > > > > I am trying to convert this structured array to a 2D array. Is this > possible where th

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

2016-02-26 Thread Ek Esawi
Hi All— I used genfromtxt to read a file with multiple data types. The result was a 1D array of tuples; for example [(1, 2, 3), (‘a’, b’, ’c’), (‘12/12/2009’, ’2/4/2014’, ‘3/4/200)’] I am trying to convert this structured array to a 2D array. Is this possible where the data types in the 1D a