Issue
I have a small question re: np.random.seed(seed=x)
I have a df SEED = 1
column of seed numbers
I would like to generate random number after choosing a seed from my df SEED
For example in the first simulation I'll use seed no 100 of the df SEED
and in the next simulation, I want to use seed no 200 of the SEED
df.
I've been trying out things , but to no avail.
Any hints for me?
Cheers
Solution
It seems you need loop by values of column SEED
and set np.random.seed(x)
:
df = pd.DataFrame({'SEED':[100,200,500]})
print (df)
SEED
0 100
1 200
2 500
for i, x in df['SEED'].items():
print (x)
np.random.seed(x)
#some random function
a = np.random.randint(10, size=5)
print (a)
100
[8 8 3 7 7]
200
[9 0 4 7 9]
500
[7 1 1 8 7]
If need generate random value from list:
L = [100,200,500]
a = np.random.choice(L, size=1)[0]
np.random.seed(a)
print (a)
500
Answered By - jezrael
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.