On 2/18/10 5:17 PM, Luca Beltrame wrote: > Hello, > > In my porting effort (using a frequently updated rpy2.1 copy from mercurial) I > found myself in the necessity of subsetting values from a DataFrame. In R I > would do this, for example > > subset(my_data_frame, Column_name> 0) > > however in Python keywords cannot be expressions. > > How would I handle such a case?
Currently, you will have to repeat the data.frame in which the column of interest is located. base = importr('base') base.subset(my_data_frame, my_data_frame.rx('Column_name').ro > 0) L. PS: Operators such as ">" and "<" are only available in a very recent snapshot for rpy2-2.1dev. Example from the documentation: x.rx(x.ro > 3) # extract values > 3 i = (x.ro >= 2 ).ro & (x.ro <= 4) # extract values between 2 and 4 x.rx(i) PPS: The required use of .ro may disappear. More about that on in an other email to the list > Thanks! > > > > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > > > > _______________________________________________ > rpy-list mailing list > rpy-list@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/rpy-list ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ rpy-list mailing list rpy-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rpy-list