numpy/ones

Ones

Create array filled with ones

numpy
array
init

Command

np.ones((rows, cols))

Explanation

Initializes an array of given shape with ones.

Examples

2x4 array of ones

np.ones((2, 4))