'How to create an array where each element is equal to its row number?
I was wondering how I can assign each element in an array to be equal to its row number. For example an array of,
Row number: 1,2,3,4,5,6,7,8,9,10
Elementnum: 1,2,3,4,5,6,7,8,9,10
import numpy as np
array=np.ones(10)
#What next?
This will be done with large row numbers of n=1000 so I won't manually be able to do it.
Thanks
Solution 1:[1]
np.arange(1, 1000) if you want a 1-based numbering.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | nnnmmm |
