ltq477
ltq477

Reputation: 61

np.random.randint: ValueError: low >= high

getting a high low error on this. Works with another 1D dataframe and dtype but not on this. I'm trying to create a list of means taken randomly from a 1D list. Thanks!

new = []
for x in df:
    sb_ = np.random.randint(x, size=100).mean()
    new.append(sb_)   

Upvotes: 3

Views: 20739

Answers (1)

DerekG
DerekG

Reputation: 3938

numpy.random documentation here. If only one input parameter is given as in your case, that input is the lower end of the range, and high is taken as 0. So, if any x in df is less than 0 (we'll say x', this code tries to draw a random integer from the range [0,x'], which is an empty range (no possible values). Thus your high-low error.

Based on your code and description it's a bit unclear exactly what you're trying to accomplish but with a bit more detail I can probably help you work out the correct code.

Upvotes: 4

Related Questions