how to create a numpy array with constant value

Solutions on MaxInterview for how to create a numpy array with constant value by the best coders in the world

showing results for - "how to create a numpy array with constant value"
Jayda
20 Jan 2017
1>>> np.full((3, 5), 7)
2array([[ 7.,  7.,  7.,  7.,  7.],
3       [ 7.,  7.,  7.,  7.,  7.],
4       [ 7.,  7.,  7.,  7.,  7.]])
5
6>>> np.full((3, 5), 7, dtype=int)
7array([[7, 7, 7, 7, 7],
8       [7, 7, 7, 7, 7],
9       [7, 7, 7, 7, 7]])
10