mardi 12 novembre 2019

Python - Generating a New List Randomly From Two Other Lists

I have two lists, high and low bounds, that I would like to use as bounds to create a new list randomly between those values.

LOW     HIGH
19.35   45.04
18.09   44.05
17.44   42.07
16.46   41.95
18.38   43.45
20.78   46.04
24.99   49.12
25.22   50.94
24.67   49.32

I am trying to create a new list that has the length of list but has random values between each LOW and HIGH pair.

A new list might look like:

NEW LIST
38.26
33.70
18.47
41.35
36.77
21.95
25.23
29.18
49.32

Any help is appreciated, thanks!

So far this is what I have but it doesn't step down a row to update the lower and upper bounds:

Low = pd.Series(data['LOW']).values
High = pd.Series(data['HIGH']).values

newlist = []

for i in range(0, 8):
        newlist = random.uniform(Low, High)



Aucun commentaire:

Enregistrer un commentaire