[Tutor] Get a single random sample

kitty kitty.a1000 at gmail.com
Fri Sep 9 12:44:10 CEST 2011


I'm new to python and I have read through the tutorial on:
which was really good, but I have been an R user for 7 years and and am
finding it difficult to do even basic things in python, for example I want
to import my data (a tab-delimited .txt file) so that I can index and select
a random sample of one column based on another column. my data has
2 columns named 'area' and 'change.dens'.

In R I would just

data<-read.table("FILE PATH\\Road.density.municipio.all.txt", header=T)
#header =T gives colums their headings so that I can call each individually

Then to Index I would simply:
subset<-change.dens[area<2000&area>700] # so return change.dens values that
have corresponding 'area's of between 700 and 2000

then to randomly sample a value from that I just need to

My question is how do I get python to do this???

Sorry I know it is very basic but I just cant seem to get going,

Thank you
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110909/d0a20884/attachment.html>

More information about the Tutor mailing list