Reputation: 397
How can I create a numpy array which has values in a specific range. For instance only from 2 to 10! I know that np.arrange(10)
will create an array with 10 values from 0 to 9 but not sure how to indicate that I want it to have values in a specific range. Any idea? Thanks in advance
Upvotes: 7
Views: 16324
Reputation: 1
It should be like:
import numpy as np
x = np.arange(2,11)
print(x)
Upvotes: 0
Reputation: 4488
As others and the documentation says
np.arange(2,11)
Here is a working example https://repl.it/@Sudakatux/simplenumpy
Here are the docs: https://docs.scipy.org/doc/numpy/reference/generated/numpy.arange.html
Upvotes: 6