Re: best way to do this
On Dec 2, 10:09 pm, TP <[EMAIL PROTECTED]> wrote: > Hi everybody, > > >>> c=[(5,3), (6,8)] > > From c, I want to obtain a list with 5,3,6, and 8, in any order. > I do this: > > >>> [i for (i,j) in c] + [ j for (i,j) in c] > > [5, 6, 3, 8] > > Is there a quicker way to do this? > >>> c = [(5, 3), (6, 8)] >>> [x for t in zip(*c) for x in t] [5, 6, 3, 8] -- http://mail.python.org/mailman/listinfo/python-list
Re: list comprehension question
On May 1, 2:28 pm, Arnaud Delobelle wrote: > Ross writes: > > If I have a list of tuples a = [(1,2), (3,4), (5,6)], and I want to > > return a new list of each individual element in these tuples, I can do > > it with a nested for loop but when I try to do it using the list > > comprehension b = [j for j in i for i in a], my output is b = > > [5,5,5,6,6,6] instead of the correct b = [1,2,3,4,5,6]. What am I > > doing wrong? > > When writing nested list comprehension, the for loops are in the same > order as you would write a normal nested for loop (which is not > necessarily intuitive when you first find out but is very handy in the > long run I think). > > So write: > > [j for i in a for j in i] > > -- > Arnaud an trick >>> a [(1, 2), (3, 4), (5, 6)] >>> sum(a, ()) (1, 2, 3, 4, 5, 6) >>> you may search the maillist , somebody questioned before -- http://mail.python.org/mailman/listinfo/python-list
Parallel python + ??
Hi, I am running a program using Parallel Python and I wonder if there is a way/module to know in which CPU/core the process is running in. Is that possible? Ángel -- http://mail.python.org/mailman/listinfo/python-list
Re: Parallel python + ??
Gerhard Häring wrote: > This is of course OS-specific. On Linux, you can parse the proc > filesystem: > > >>> open("/proc/%i/stat" % os.getpid()).read().split()[39] > > You can use the "taskset" utility to query or set CPU affinity on Linux. > It is going to be in Linux (mainly) I was thinking about something like this: import Module def process(self): print "I am running on processor", Module.cpu,"core", Module.core Checking the raskset right now...:) Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: More like a shell command.
Maybe this module would work fine: http://docs.python.org/lib/module-cmd.html -- Angel -- http://mail.python.org/mailman/listinfo/python-list
Data peeping function?
The first thing I do once I import new data (as a pandas dataframe) is to .head() it, .describe() it, and then kick around a few specific stats according to what I see. But I'm not satisfied with .describe(). Amongst others, non-numerical columns are ignored, and off-the-shelf stats will be computed for any numerical column. I've been shopping around for a "data peeping" function that would: (1) Have a hands-off mode where simply typing diagnose_this(data) the function would figure things out on its own, and notify me when in doubt. For example, would assume that any string data with not too many unique values should be considered categorical and appropriate statistics erected. (2) Perform standard diagnoses and print them out. For example, (a) missing values? (b) heterogeneously formatted data? (c) columns with only one unique value? etc. (3) Be parametrizable, if I so choose. Does anyone know of such a function? -- https://mail.python.org/mailman/listinfo/python-list
Re: Access lotus notes using Python
Sateesh wrote: > Hi, > Is it possible to access Lotus notes using Python? Can anyone provide me > some pointers? > > Thanks > Sateesh > > NotesSQL is an ODBC driver for Notes. Using NotesSQL and a python odbc connection you can use the standard python db-api2 to access tables. (Examples of odbc connection: mxODBC or the odbc provided by win32all) HTH, Thor Arne Johansen Technical Director Ibas AS -- http://mail.python.org/mailman/listinfo/python-list