lundi 18 juillet 2022

How to obtain the same array with the same seed value in a different time?

I need to have a random array.

seed1 = 5010
I_O =pd.DataFrame(float(0),index=list(I_O_indices) , columns=list(I_O_column))
RandomSeed1 = np.random.seed(seed1)
Rack2 = pd.DataFrame(np.random.choice(np.arange(n),size=(height, width), replace=False), index=list(indices), columns=list(column))
Rack = Rack2.sort_index(ascending=False)

a = np.hstack([np.repeat(0, samp_size), np.repeat(1, samp_size), np.repeat(np.nan, n - (2 * samp_size)) ])
RandomSeed1 = np.random.seed(seed1)
b = np.random.shuffle(a)
a = a.reshape(Rack.shape)

SI = Rack.where(a==0)
RI = Rack.where(a==1)

dfStorage = SI.stack()
ss=dfStorage.index

D3 = RI.stack()
tt=D3.index

S = dfStorage.values.reshape(-1).tolist() 
R = D3.values.reshape(-1).tolist()

When I first run this code, I have the array below for SI:

enter image description here

But when I tried after I have different SI array like that; enter image description here

How can I get the same array?




Aucun commentaire:

Enregistrer un commentaire