numpy.asfarray

numpy.asfarray(a, dtype=<type 'numpy.float64'>)

Return an array converted to float type.

Parameters:

a : array_like

Input array.

dtype : string or dtype object, optional

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

Returns:

out : ndarray, float

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.])

Previous topic

numpy.asmatrix

Next topic

numpy.asfortranarray

This Page

Quick search