Trying to use sets for random selection, but the pop() method returns items in order
Paul Rubin
http
Wed Jul 1 20:48:46 EDT 2009
Mario Garcia <Mariosky at gmail.com> writes:
> Im trying to use sets for doing statistics from a data set.
> I want to select, 70% random records from a List. I thougth set where
> a good idea so I
No that's not a good idea. When the set/dict documentation says you
get the keys in an undetermined order, it doesn't mean the ordering is
random. It means there is a fixed ordering controlled by the
implementation and not by you.
If you want a random sample, use random.sample(). See the docs for
the random module.
More information about the Python-list
mailing list