9951 explained code solutions for 126 technologies


python-numpyGenerate Numpy ones array with custom datatype


import numpy as np
a = np.ones((2, 3),dtype='float64')ctrl + c
import numpy as np

load Numpy module for Python

np.ones

generates ones array

(2, 3)

generated array dimensions (2x3 in our case)

dtype='float64'

data type of generated array. See here for a list of data types.