numpy.asfarray

numpy.asfarray(a, dtype=<class 'numpy.float64'>) [source]

Return an array converted to a float type.

Parameters
aarray_like

The input array.

dtypestr or dtype object, optional

Float type code to coerce input array a. If dtype is one of the ‘int’ dtypes, it is replaced with float64.

Returns
outndarray

The input a as a float ndarray.

Examples

>>> np.asfarray([2, 3])
array([2.,  3.])
>>> np.asfarray([2, 3], dtype='float')
array([2.,  3.])
>>> np.asfarray([2, 3], dtype='int8')
array([2.,  3.])

© 2005–2020 NumPy Developers
Licensed under the 3-clause BSD License.
https://numpy.org/doc/1.19/reference/generated/numpy.asfarray.html