Re: what is happening in panda "where" clause

2017-09-23 Thread Pavol Lisy
On 9/22/17, Peter Otten <__pete...@web.de> wrote: > Exposito, Pedro (RIS-MDW) wrote: > >> This code does a "where" clause on a panda data frame... >> >> Code: >> import pandas as pd; >> col_names = ['Name', 'Age', 'Weight', "Education&qu

Re: what is happening in panda "where" clause

2017-09-22 Thread Peter Otten
Exposito, Pedro (RIS-MDW) wrote: > This code does a "where" clause on a panda data frame... > > Code: > import pandas as pd; > col_names = ['Name', 'Age', 'Weight', "Education"]; > # create panda dataframe > x = pd.read_csv('test.dat'

what is happening in panda "where" clause

2017-09-22 Thread Exposito, Pedro (RIS-MDW)
This code does a "where" clause on a panda data frame... Code: import pandas as pd; col_names = ['Name', 'Age', 'Weight', "Education"]; # create panda dataframe x = pd.read_csv('test.dat', sep='|', header=None, names = col_names); # apply "where" co

Escaping optional parameter in WHERE clause

2009-03-23 Thread someone
Hi, as you can see below I have some optional parameter for my query (mf, age). They are in WHERE clause only if not empty. In this function they are not escaped as, for example, 'search' parameter, cause I can't pass them to execute function, which does escaping automatically. I could write

Re: Escaping optional parameter in WHERE clause

2009-03-23 Thread MRAB
someone wrote: Hi, as you can see below I have some optional parameter for my query (mf, age). They are in WHERE clause only if not empty. In this function they are not escaped as, for example, 'search' parameter, cause I can't pass them to execute function, which does escaping automatically

Re: Escaping optional parameter in WHERE clause

2009-03-23 Thread andrew cooke
note that your version is open to sql injection attacks, while mrab's reply isn't. andrew someone wrote: if mf: mf = AND mf = %s % mf if age: age = AND age = %s % age -- http://mail.python.org/mailman/listinfo/python-list

Re: Escaping optional parameter in WHERE clause

2009-03-23 Thread andrew cooke
ah, sorry, from title i guess you were aware of this. andrew andrew cooke wrote: note that your version is open to sql injection attacks, while mrab's reply isn't. andrew someone wrote: if mf: mf = AND mf = %s % mf if age: age = AND age = %s

Re: Escaping optional parameter in WHERE clause

2009-03-23 Thread someon
On Mar 23, 1:48 pm, MRAB goo...@mrabarnett.plus.com wrote: someone wrote: Hi, as you can see below I have some optional parameter for my query (mf, age). They are in WHERE clause only if not empty. In this function they are not escaped as, for example, 'search' parameter, cause I can't

Re: Escaping optional parameter in WHERE clause

2009-03-23 Thread Steve Holden
MRAB wrote: someone wrote: Hi, as you can see below I have some optional parameter for my query (mf, age). They are in WHERE clause only if not empty. In this function they are not escaped as, for example, 'search' parameter, cause I can't pass them to execute function, which does escaping

where clause

2009-02-05 Thread bearophileHUGS
This comes after a small discussion in another Python newsgroup. Haskell supports a where clause, that's syntactic sugar that allows you to define things like this: p = a / b where a = 20 / len(c) b = foo(d) That means: a = 20 / len(c) b = foo(d) p = a / b I don't know how much good

Re: where clause

2009-02-05 Thread Albert Hopkins
On Thu, 2009-02-05 at 10:04 -0800, bearophileh...@lycos.com wrote: This comes after a small discussion in another Python newsgroup. Haskell supports a where clause, that's syntactic sugar that allows you to define things like this: p = a / b where a = 20 / len(c) b = foo(d

Re: where clause

2009-02-05 Thread bearophileHUGS
Albert Hopkins: One could imagine this getting out of hand e.g. Yes, any syntax can be abused (your example isn't abusive enough). a = 20 / len(c) where c = p / b try: b = foo(d) where d = bar()

Re: where clause

2009-02-05 Thread Paul Rubin
bearophileh...@lycos.com writes: Note that where may also be designed to create a new scope (as in Haskell, I think), that's why I have inlined the bar and p/b. In Haskell, where is only allowed at the outermost level of a function definition (including a nested one), not in an arbitrary

Re: where clause

2009-02-05 Thread Rhodri James
On Thu, 05 Feb 2009 18:04:35 -, bearophileh...@lycos.com wrote: p = a / b where a = 20 / len(c) b = foo(d) You'd want to do it with paired keywords, in the manner of try/except, to avoid utterly breaking Python's syntax conventions. Perhaps something like this: do: p = a / b

Re: DAO and Access97 WHERE clause fails

2007-06-10 Thread stefaan
I should point out that I don't do DAO (or ADO) -- and if I had to code Python to access JET, I'd probably hijack a copy of mxODBC in order to get a sane SQL interface. I have successfully used the dejavu object-relational mapper (http:// projects.amor.org/docs/dejavu/1.5.0RC1/) to

Re: DAO and Access97 WHERE clause fails

2007-06-09 Thread v.davis2
SELECT * FROM TableName), but have not been able to figure out how to add a WHERE clause to that (e.g., SELECT * FROM TableName WHERE myFieldName = 34) This fails complaining that the wrong number of parameters are present. I haved tried DAO36 and I have tried the ADO version with the same

DAO and Access97 WHERE clause fails

2007-06-08 Thread v.davis2
Hi all, I am attempting to use Access97 as the database to hold the results of a python script. I seem to be able to make simple SELECT clauses work (like SELECT * FROM TableName), but have not been able to figure out how to add a WHERE clause to that (e.g., SELECT * FROM TableName WHERE

Re: DAO and Access97 WHERE clause fails

2007-06-08 Thread John Machin
On Jun 9, 10:17 am, v.davis2 [EMAIL PROTECTED] wrote: Hi all, I am attempting to use Access97 as the database to hold the results of a python script. I seem to be able to make simple SELECT clauses work (like SELECT * FROM TableName), but have not been able to figure out how to add a WHERE