Effective data sharing in Python

Consider the 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'm trying to do in this code is to randomly split my data in a Sales Sframe (which is similar to a Pandas DataFrame) into about 4 equal parts.

What is a Pythonic / Effective Way to Achieve This?

+5
source share
1 answer
 np.random.seed(0) np.random.shuffle(arr) # in-place sets = np.array_split(arr, 4) 
+2
source

Source: https://habr.com/ru/post/1238532/


All Articles