Re: [Tutor] Python OLS help
On Tue, May 31, 2016 at 5:45 PM Vadim Katsemba wrote: > I typed in lm = smf.ols(formula='LATITUDE~DIAMETER',data=dataf).fit(), and > I ended up getting this error: ValueError: For numerical factors, > num_columns must be an int. > You may be using an old version of Patsy, the module that allows you to specify your OLS formula like R-lang does. What version of patsy are you using? This seems to have been a problem with Patsy v0.4.0 and was fixed in v0.4.1 (as per an email thread I read [0]) [0] https://groups.google.com/forum/#!topic/pystatsmodels/KcSzNqDxv-Q ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python OLS help
You're welcome. A tip for the next bug: Google is pretty good at finding a discussion of the error if you paste the whole phrase as your search terms. In this case, I searched for "ValueError for numerical factors num_columns must be an int" and found the relevant Google Group thread. PS. I replied to the mailing list in case someone else has the same issue. These emails are archived and searchable. On Tue, May 31, 2016 at 10:07 PM Vadim Katsemba wrote: > I upgraded to patsy 0.4.1 and got the regression to run. Thank you very > much for your help! > > On Tue, May 31, 2016 at 8:03 PM, Michael Selik > wrote: > >> On Tue, May 31, 2016 at 5:45 PM Vadim Katsemba >> wrote: >> >>> I typed in lm = smf.ols(formula='LATITUDE~DIAMETER',data=dataf).fit(), >>> and I ended up getting this error: ValueError: For numerical factors, >>> num_columns must be an int. >>> >> >> You may be using an old version of Patsy, the module that allows you to >> specify your OLS formula like R-lang does. What version of patsy are you >> using? This seems to have been a problem with Patsy v0.4.0 and was fixed in >> v0.4.1 (as per an email thread I read [0]) >> >> [0] https://groups.google.com/forum/#!topic/pystatsmodels/KcSzNqDxv-Q >> > > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] UPDATE, pyhthon+postgre
Hello All, I am writing a UPDATE statement, but am getting stuck with the following error. Traceback (most recent call last): File "/var/www/passtms/updateCutoff.cgi", line 70, in WHERE group_code = %s;""", (name,add,add1,city,state_county,country,basic,todayDT,todayTIME,grpCode)) DataError: invalid input syntax for type timestamp with time zone: "05:27PM" LINE 18: time_created='05:27PM' ^ Table created with the following lines :- date_created date DEFAULT ('now'::text)::date, time_created timestamp with time zone DEFAULT now() With the code below, I am getting data from a HTML Form, and then I am trying to update the single record in Pg Table grpCode = form.getvalue('nameradio') name = form.getvalue('name') add = form.getvalue('add') add1 = form.getvalue('add1') city = form.getvalue('city') todayDT = form.getvalue('todayDT') todayTIME = form.getvalue('todayTIME') cursor1.execute("""UPDATE employee SET name=%s, add=%s, add1=%s, city=%s, state_county=%s, country=%s, basic=%s, date_created=%s, time_created=%s WHERE group_code = %s;""", (name,add,add1,city,state_county,country,basic,todayDT,todayTIME,grpCode)) How do I resolve this issue? Thanks Nitin ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] UPDATE, pyhthon+postgre
cursor1.execute("""UPDATE employee SET name=%s, add=%s, add1=%s, city=%s, state_county=%s, country=%s, basic=%s, WHERE group_code = %s""" % (name,add,add1,city,state_county,country,basic,grpCode)) It appears that you are not required to provide any time or date since you created a default. Of course that assumes you want today and now. If that assumption is wrong then lookup "datetime". To make life a little easier lookup the module "dateutil". You would use either of those modules to convert your python input to the correct output for postgres (actually for any sql database). Hint: if the field requires a string you should place quotes around the placeholder as in '%s'. Johnf ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] UPDATE, pyhthon+postgre
Thank you Stephen, Johnf, This is what I did and it worked :- todayTime2 = datetime.datetime.now() todayTime1 = timezone('Asia/Calcutta').localize(todayTime2) time_created=%s WHERE group_code = %s;""", ( .,...,..., str(todayTime1),)) Thanks for the Hint, Johnf :) Nitin On 1 June 2016 at 18:53, john wrote: > cursor1.execute("""UPDATE employee SET > name=%s, > add=%s, > add1=%s, > city=%s, > state_county=%s, > country=%s, > basic=%s, > WHERE group_code = %s""" % > (name,add,add1,city,state_county,country,basic,grpCode)) > > It appears that you are not required to provide any time or date since you > created a default. Of course that assumes you want today and now. > > If that assumption is wrong then lookup "datetime". To make life a little > easier lookup the module "dateutil". You would use either of those modules > to convert your python input to the correct output for postgres (actually > for any sql database). > > Hint: if the field requires a string you should place quotes around the > placeholder as in '%s'. > > Johnf > > > > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Study Tips
> On May 30, 2016, at 1:45 AM, Steve Lett wrote: > > Hi folks, > Just started learning python. I've been having a really hard time in > getting started, and still am! I have a slight learning difficulty, > including a stroke in Jan.2010. You wouldnt know even if u were here > looking at me! Praise God for the great salvation! > I have a slight learning difficulty. Has anyone got any tips on how to > study programming and what approach would be best for me? > Quick question - just to be sure everyone is on the same page. Is Python your first programming language? That is, are you comfortable with the process of decomposing a problem into a series of steps (an algorithm) that will yield an answer? Do you already know how to program in some OTHER language. If yes - the answers you have gotten are great. If NOT, then we should be talking on a whole different level. -Thanks, -Bill > Out of a long list of books that I have collected ( python, Blender, etc ) > I have decided to start on Introducing Python (hard copy 2nd Ed, ebook 3rd > ed) by Bill Lubanovic. Before that I was going to start with Python > Programming for the Absolute Beginner, Michael Dawson. > > Any thoughts on these issues and especially the study tips already > mentioned. > > Thank you, Steve > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Study Tips
Hi experts, I am going to start learning Python and have got no coding experience/knowledge whatsoever . So Python would be my first programming language Please suggest Thank you Anindya On Wednesday, June 1, 2016, William Ray Wing wrote: > > > On May 30, 2016, at 1:45 AM, Steve Lett > wrote: > > > > Hi folks, > > Just started learning python. I've been having a really hard time in > > getting started, and still am! I have a slight learning difficulty, > > including a stroke in Jan.2010. You wouldnt know even if u were here > > looking at me! Praise God for the great salvation! > > I have a slight learning difficulty. Has anyone got any tips on how to > > study programming and what approach would be best for me? > > > > Quick question - just to be sure everyone is on the same page. Is Python > your first programming language? That is, are you comfortable with the > process of decomposing a problem into a series of steps (an algorithm) that > will yield an answer? Do you already know how to program in some OTHER > language. If yes - the answers you have gotten are great. If NOT, then we > should be talking on a whole different level. > > -Thanks, > -Bill > > > > Out of a long list of books that I have collected ( python, Blender, etc > ) > > I have decided to start on Introducing Python (hard copy 2nd Ed, ebook > 3rd > > ed) by Bill Lubanovic. Before that I was going to start with Python > > Programming for the Absolute Beginner, Michael Dawson. > > > > Any thoughts on these issues and especially the study tips already > > mentioned. > > > > Thank you, Steve > > ___ > > Tutor maillist - Tutor@python.org > > To unsubscribe or change subscription options: > > https://mail.python.org/mailman/listinfo/tutor > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > -- Best regards Anindya ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] OrderedDict?
Hi list, I'm trying to find the OrderedDict documentation. I found one page, but it wasn't very clear on how to actually make an OrderedDict. Plus, an empty constructor in Python's interpreter returns an error that the class doesn't exist (Python 2.7.11). I also found the PEP, plus some home-grown suggestions on how to implement this, but so far that's it. Although I thought this was in 2.7, it doesn't appear on the Data Structures page at all. What am I missing? Thanks. -- Alex Hall Automatic Distributors, IT department ah...@autodist.com ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Study Tips
Gday! On 31/05/2016 8:52 AM, "Steve Lett" wrote: > Thank you for the reply. > On 30/05/2016 3:45 PM, "Steve Lett" wrote: > >> Hi folks, >> Just started learning python. I've been having a really hard time in >> getting started, and still am! I have a slight learning difficulty, >> including a stroke in Jan.2010. You wouldnt know even if u were here >> looking at me! Praise God for the great salvation! >> I have a slight learning difficulty. Has anyone got any tips on how to >> study programming and what approach would be best for me? >> >> Out of a long list of books that I have collected ( python, Blender, etc >> ) I have decided to start on Introducing Python (hard copy 2nd Ed, ebook >> 3rd ed) by Bill Lubanovic. Before that I was going to start with Python >> Programming for the Absolute Beginner, Michael Dawson. >> >> Any thoughts on these issues and especially the study tips already >> mentioned. >> >> Thank you, Steve >> > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Tutor Digest, Vol 147, Issue 52
Thanks for your replies,I think I understand it much better now. I Also I wanted to know what the 'None' does in the second program. Thanks in Advance Minhaj On Wed, Jun 1, 2016 at 1:59 AM, wrote: > Send Tutor mailing list submissions to > tutor@python.org > > To subscribe or unsubscribe via the World Wide Web, visit > https://mail.python.org/mailman/listinfo/tutor > or, via email, send a message with subject or body 'help' to > tutor-requ...@python.org > > You can reach the person managing the list at > tutor-ow...@python.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Tutor digest..." > > Today's Topics: > >1. Help with 'if' statement and the concept of None (marat murad) >2. Python OLS help (Vadim Katsemba) >3. Re: Help with 'if' statement and the concept of None (Alan Gauld) >4. Re: Python OLS help (Alan Gauld) >5. Re: Help with 'if' statement and the concept of None > (Steven D'Aprano) >6. Re: Help with 'if' statement and the concept of None (Ben Finney) > > > -- Forwarded message -- > From: marat murad > To: tutor@python.org > Cc: > Date: Tue, 31 May 2016 16:16:21 +0100 > Subject: [Tutor] Help with 'if' statement and the concept of None > Hi > I'm learning how to code with python an I have purchased the book 'Python > Programming for the absolute beginner,third edition' by Michael Dawson. > There is one concept that is confusing me in chapter 3 page 71 there is a > program whose code I have pasted below. The author introduced a new way of > coding the Boolean NOT operator with the 'if' statement I have highlighted > the relevant area,apparently this if statement actually means if money != > 0,which I understood,but the program below this one which introduces the > idea of slicing also has a if statement similar to the first one,except the > second one accepts 0 value but the first one doesn't. > > print("Welcome to the Chateau D'food") > print("It seems we are quit full today.\n") > > money = int(input("How many dollars do you slip the Maitr D'? ")) > > *if money:* > print("Ah I think I can make something work") > else: > print("Please sit ,it may be a while") > > > input("\nPress enter to exit") > > > The slicing program > > word = "existential" > > print("Enter the beginning and ending index for the word existential") > print("press he enter key at 'Start' to exit") > > start= None > while start != "": > start=input("\nStart: ") > >* if start:* > start=int(start) > > finish=int(input("Finish: ")) > > print ("word[",start, ":",finish, "]is " , end="") > print(word[start:finish]) > > input("\nPress enter to exit") > > I hope i made sense. > > Thankyou > > > > -- Forwarded message -- > From: Vadim Katsemba > To: tutor@python.org > Cc: > Date: Tue, 31 May 2016 11:30:29 -0400 > Subject: [Tutor] Python OLS help > Hello there, I am having trouble running the Ordinary Least Squares (OLS) > regression on Spyder. I typed in lm = > smf.ols(formula='LATITUDE~DIAMETER',data=dataf).fit(), and I ended up > getting this error: ValueError: For numerical factors, num_columns must be > an int. How am I supposed to run the OLS, is there another module I need to > use? Any help would be appreciated. > > > > -- Forwarded message -- > From: Alan Gauld > To: tutor@python.org > Cc: > Date: Tue, 31 May 2016 23:06:47 +0100 > Subject: Re: [Tutor] Help with 'if' statement and the concept of None > On 31/05/16 16:16, marat murad via Tutor wrote: > > > program whose code I have pasted below. The author introduced a new way > of > > coding the Boolean NOT operator with the 'if' statement I have > highlighted > > the relevant area,apparently this if statement actually means if money != > > 0,which I understood, > > Boolean values are either true or false. > Other values are given boolean equivalent values by Python. > eg. For strings an empty string is False, anything else is True. > For numbers 0 is False anything else is True. > > So in your example: > > > *if money:* > > print("Ah I think I can make something work") > > else: > > print("Please sit ,it may be a while") > > > > The first 'if' test is saying > > 'if money is equivalent to True' (anything other than zero) > > In effect that's the same as you said (it's like testing for != 0) > but the important difference is that it is relying > on the boolean *equivalence* of an integer value. > The same is true in your second example: > > > idea of slicing also has a if statement similar to the first one,except > the > > second one accepts 0 value but the first one doesn't. > > > > > start=input("\nStart: ") > > > >* if start:* > > start=int(start) > > Again this is really saying if start is True and for a string > (which is what input() returns), as I said above, True means > not empty. So the string '0' is not empty and therefore True.
Re: [Tutor] Study Tips
On 01/06/16 20:06, Anindya Mookerjea wrote: > Hi experts, > > I am going to start learning Python and have got no coding > experience/knowledge whatsoever . So Python would be my first programming > language Start with one of the tutorials on the non-programmers page of python.org http://wiki.python.org/moin/BeginnersGuide/NonProgrammers If you are comfortable with IT things in general (editing files, navigating directories etc) then you could try mine(see below) -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] OrderedDict?
On 01/06/16 16:36, Alex Hall wrote: > I'm trying to find the OrderedDict documentation. I found one page, but it > wasn't very clear on how to actually make an OrderedDict. Plus, an empty > constructor in Python's interpreter returns an error that the class doesn't > exist It's in the collections module: >>> import collections as coll >>> help(coll.OrderedDict) ... >>> od = coll.OrderedDict() >>> od OrderedDict() >>> HTH -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] Use of None (was: Re: Tutor Digest, Vol 147, Issue 52)
On 01/06/16 12:43, marat murad via Tutor wrote: > Thanks for your replies,I think I understand it much better now. I Also I > wanted to know what the 'None' does in the second program. Please make the subject something meaningful and delete all the excess messages. we have all seen them already and some people pay by the byte. As for none, it just means a reference to nothing. ie no object. So in your example: start= None while start != "": start=input("\nStart: ") ... The start = None could have been replaced by anything other than an empty string. It just creates an initial value that causes the while loop to start. You will often find None used like this: to create a named value that has no significance at that point in the program but will be used later. Another way of writing your example would be: while True: # loop forever start = input(...) if start = "": break # break exits the nearest loop ... HTH -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor