Let's say I have an array of strings which take the format of dates in a YYYYMMDD format. For example:
masterlist = ['20190701', '20190702', ... '20190731']
Let's say I want to create a new series of 3 lists with lengths of x, y, and z. For this example, we can simply say x = 20, y = 10, and z = 1. The format is such that I would like to loop through all of the elements in masterlist to set as z. From here, I want to take 20 random dates which do not contain the date in z and assign those to x. Lastly, those dates not in x or z, will be left for y. In other words, no list should have the same date.
For example:
z = ['20190701']
x = ['20190702', ... , '20190721']
y = ['20190722', ... , '20190731']
And another:
z = ['20190702']
x = ['20190701', '20190703', ..., '20190720']
y = ['20190722', ... , '20190731']
It does not matter the order or random mixing between x and/or y, so long as the lists are mutually exclusive and collectively exhaustive.
What is the simplest way to achieve this?
random.sample