Consider following code
one, two = sales.random_split(0.5, seed=0)
set_1, set_2 = one.random_split(0.5, seed=0)
set_3, set_4 = two.random_split(0.5, seed=0)
What I am trying to in this code is to randomly split my data in Sales
Sframe (which is similar to Pandas DataFrame) into roughly 4 equal parts.
What is a Pythonic/Efficient way to achieve this?
np.random.seed(0)
np.random.shuffle(arr) # in-place
sets = np.array_split(arr, 4)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With