I am having a hard time formulating my question so I'll just show by example.
x = ['abc', 'c', 'w', 't', '3']
a, b = random_split(x, 3) # first list should be length 3
# e.g. a => ['abc', 'w', 't']
# e.g. b => ['c', '3']
Is there an easy way of splitting a list into two random samples while maintaining the original ordering?
edit I know that I could use random.sample and then reorder, but I was hoping for an easy, simple, one line method.
No comments:
Post a Comment