[Tutor] cvxopt install problem

2015-11-04 Thread Ek Esawi
Hi All-- I posted this question to another group but have not gotten any input. I needed to install cvxopt on a 64 bit W7. I found out that cvxopt is incompatible with a 64 bit. It only compatible with a 32 bit which can be installed on a 64 bit computer and it works. I stumbled on this on ano

[Tutor] cvxopt install problem

2015-11-05 Thread Ek Esawi
Thank you Alan and Michael for your input. Alan was right on what happened; that’s my mistake was that I used IDEL instead of CMD to install cvx. Once I used CMD all went well. I am hoping that cvx will work now w/o any issue. I used it on matlab. I am an experienced numerical programmer but new

[Tutor] Extract several arrays from a large 2D array

2016-01-21 Thread Ek Esawi
Hi All-- I have a 2D array (2000, 4); an example is given abelow. On the 1st column I have 15 variables, on the 2nd 4 variables. Ignore column 3 for now. I want a code that generate 4 arrays for each variable on the 1st column; each array contains all the values from column 4. Then I want to fi

[Tutor] Extract several arrays from a large 2D array

2016-01-22 Thread Ek Esawi
Thank you all for your help. I am a decent programmer in another language but new to Python and I have some issues with a project I am working on. Some suggested using pandas but I am barley starting on Numpy. The suggestions were very helpful, however, I decided to replace the 2D array with severa

[Tutor] Change datatype for specific columns in an 2D array & computing the mean

2016-01-23 Thread Ek Esawi
'19' 'A4' 'B2' '2'] ['19' 'A5' 'B1' '12'] ['18' 'A5' 'B2' '121']] Thanks in advance EK Esawi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Change datatype for specific columns in an 2D array & computing the mean

2016-01-24 Thread Ek Esawi
Thanks for the input. Columns 2 and 3 are strings and i assume that they don't need to be converted. Because all i need is to compute the mean for data on column 4 based on each variable in column 1 and each in column 2.. BTW, is it possible to send you what i did off list? That way you see what i

Re: [Tutor] Change datatype for specific columns in an 2D array & computing the mean

2016-01-26 Thread Ek Esawi
. Thank you all for your continuous help and dedication to this great siteEKE ++ Code++ import numpy as np import csv DataMat=[] np.set_printoptions(precision=2) with open('c:/Users/EK Esawi/My Documents/Python Scripts/TestFile1.csv') as Test1: reader = csv.reader(Test1,

Re: [Tutor] Change datatype for specific columns in an 2D array & computing the mean

2016-01-26 Thread Ek Esawi
Sorry! but it's a csv file. I just copied it directly from an opened csv file in excel. And you're correct it looks like what you wrote. EKE ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mai

Re: [Tutor] Change datatype for specific columns in an 2D array & computing the mean

2016-01-27 Thread Ek Esawi
Here is the file. AA,BB,CC,DD,EE 1,A1,B1,11.2,11/20/2011 2,A2,B2,2.5,10/21/2011 3,A3,B3,13.67,9/21/2011 4,A4,B4,14.2,8/22/2011 5,A5,B5,20,7/23/2011 ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.p

Re: [Tutor] Change datatype for specific columns in an 2D array & computing the mean

2016-01-27 Thread Ek Esawi
Sorry for the mishap. There are no blank lines on the file. I just did not delete the blank lines when i copied and pasted. Here it's again. EK *AA,BB,CC,DD,EE* *1,A1,B1,11.2,11/20/2011* *2,A2,B2,2.5,10/21/2011* *3,A3,B3,13.67,9/21/2011* *4,A4,B4,14.2,8/22/2011* *5,A5,B5,20,7/23/2011* ___

Re: [Tutor] Change datatype for specific columns in an 2D array & computing the mean

2016-01-27 Thread Ek Esawi
Ops..here is the text file.; previously i copied and pasted from either Word or Excel. AA,BB,CC,DD,EE 1,A1,B1,11.2,11/20/2011 2,A2,B2,2.5,10/21/2011 3,A3,B3,13.67,9/21/2011 4,A4,B4,14.2,8/22/2011 5,A5,B5,20,7/23/2011 ___ Tutor maillist - Tutor@python.o

Re: [Tutor] Change datatype for specific columns in an 2D array & computing the mean

2016-01-28 Thread Ek Esawi
Thank you SO MUCH Oscar and others. This is exactly what i wanted to get. I think i can take it form here. I spent hours looking at different ways to figure it out and i came close. I tried numpy.genfromtxt, numpy.loadtext, json, etc. I am at the moment learning how to open various data files with

[Tutor] Enumerate vs DictReader object manipulation:

2016-02-03 Thread Ek Esawi
Hi All I have a code that reads a csv file via DictReader. I ran into a peculiar problem. The python interpreter ignores the 2nd code. That is if I put the reader iterator 1st, like the code below, the enumerate code is ignored; if I put the enumerate code 1st, the reader code is ignored. I am

Re: [Tutor] Enumerate vs DictReader object manipulation:

2016-02-03 Thread Ek Esawi
Thank you all. The only reason i tried both ways is to experiment with Python. They made sense to me and thought why not try them both. And i am relatively new to Python. Thanks again--EKE ___ Tutor maillist - Tutor@python.org To unsubscribe or change

[Tutor] genfromtxt vs. reading csv to a list or dictionary

2016-02-08 Thread Ek Esawi
Hi all— I normally need to convert csv and text files to a Numpy array. I tried to do the same thing using (1) reader=DictReader(MyFile), (2) reader=csv.readre(MyFile), or (3) genfromtxt (MyFile ,……). The first two is after I open the file. They produce a list of lists, list of tuples or list o

Re: [Tutor] genfromtxt vs. reading csv to a list or dictionary

2016-02-11 Thread Ek Esawi
Thanks Danny! I realized that I should not be concerned with speed/efficiency since I am a beginner in python and giving the data I work with, speed is not that important now. I am learning how to read files via several ways and transform them to numpy arrays. I just thought genfromtxt provides m

Re: [Tutor] Python for Grade 12 Calculus

2016-02-12 Thread Ek Esawi
I am not sure of the level of your students but computing the Jacobin and directional derivative where they can use both calculus and linear algebra; numerical differentiation and integration would be another topic. There are several books with nice numerical recipes that can be programmed using py

[Tutor] genfromtx- date and time conversions

2016-02-14 Thread Ek Esawi
I am using genfromtxt to read a csv file with data types that include string, float, integer, date, and time. I was able to accomplish such a task using reader. I thought there might be easier ways and the one I thought about is genfromtxt. I have 2 questions: (1) Is there a function (method) to

[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

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-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 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

[Tutor] genfromtxt and dtype to convert data to correct format

2016-05-17 Thread Ek Esawi
Hi All— I am reading data from a file using genfromtxt. A part of my data (input, output, and desired output) is shown below which consists of string, integer, time, and date type data. I want to read the data so that the output comes out in the correct format (the desired output as shown below)

Re: [Tutor] genfromtxt and dtype to convert data to correct format

2016-05-18 Thread Ek Esawi
OPS! Sorry, I made a mistake on the posting. My output is in a string format as shown below. I want the 1st and 8th integers, the 3rd string which is OK as, the 2nd date and the rest time. I tried several combinations of dtype but could not get the date and time data to without the single quote -st

Re: [Tutor] genfromtxt and dtype to convert data to correct format

2016-05-18 Thread Ek Esawi
Thanks Sydney. The print statement prints items w/o quotation marks, but doesn't change the type. I want the datatype to be changed. I am thinking it can eb done with astructured array dtyep but have not been able to get to wort. Thanks again--EK ___ Tu

Re: [Tutor] genfromtxt and dtype to convert data to correct format

2016-05-19 Thread Ek Esawi
Thanks Alan! Taking the strtime off did not work either and printed dattime.dattime(very long date format). I was able to get the integer and string parts fixed via dtype, but could not do the same for date and time. I have a feeling that structured arrays might do the trick but don't know yet how

Re: [Tutor] genfromtxt and dtype to convert data to correct format

2016-05-19 Thread Ek Esawi
).strftime('%Y-%m-%d') CF1 = lambda time: datetime.strptime(bytes.decode(time), '%H:%M').strftime('%H:%M:%S') MyFile='c:/Users/EK Esawi/My Documents/Temp/GOSA-3.csv' CRNs={'Date': CF,'Time':CF1,'Interval':CF1,'Duration&#x

Re: [Tutor] genfromtxt and dtype to convert data to correct format

2016-05-20 Thread Ek Esawi
Thanks again Alan for your help and patience. Your earlier suggestion works; i just now realized that the output was indeed correct. Thanks again--EK ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.pytho

Re: [Tutor] Loop in pre-defined blocks

2016-06-13 Thread Ek Esawi
Here is a beginner code that might work for you. Best of luck. EK b=[12, 20, 35] for i in range(len(b)): if i==0: c=0 else: c=b[i-1] for j in range(c, b[i]): print(i+1,j+1) ___ Tutor maillist - Tutor@pyth

Re: [Tutor] Loop in pre-defined blocks

2016-06-13 Thread Ek Esawi
OPS! This code now produces desired results. I suppose that this works for smaller blocks. For larger blocks, it might be cumbersome. EK b=[12, 20, 35] for i in range(len(b)): if i==0: c=0 elif i==2: c=24 else: c=b[i-1] for j in range(c, b[i]):

[Tutor] Converting a sequence of dictionaries to a single dictionary

2016-06-22 Thread Ek Esawi
Hi All-- I am trying to read a csv file via DictReader and produce a single dictionary without fieldnames; that is, I just want a single dictionary that contains tests as keys and grades as values as shown below in my sample file. If I loop through the reader, it produces a sequence of 2 entr

[Tutor] Most efficient way to read large csv files with properly converted mixed data types.

2016-06-25 Thread Ek Esawi
Hi All-- My work involves reading large csv files with mixed data types (integer, float, string, time and date). I was able to accomplish the task using (1) genfromtxt or (2) looping through each line in the file and split, strip, and assign data type to each entry. I am wondering if there is

Re: [Tutor] Most efficient way to read large csv files with properly converted mixed data types.

2016-06-26 Thread Ek Esawi
The first step of my plan is to do basic statistical analysis. The 2nd step is to chose a sample from each file and do more advanced statistical analysis for which i plan to use R. EKE ___ Tutor maillist - Tutor@python.org To unsubscribe or change subs