numpy.find_common_type()函数– Python
numpy.find_common_type()
函数根据标准强制规则确定通用类型。
Syntax : numpy.find_common_type(array_types, scalar_types)
Parameters :
array_types : [sequence] A list of dtypes or dtype convertible objects representing arrays.
scalar_types : [sequence] A list of dtypes or dtype convertible objects representing scalars.
Return : [dtype] The common data type, which is the maximum of array_types ignoring scalar_types, unless the maximum of scalar_types is of a different kind.
代码#1:
# Python program explaining
# numpy.find_common_type() function
# importing numpy as geek
import numpy as geek
gfg = geek.find_common_type([geek.float32], [geek.int64, geek.float64])
print (gfg)
输出 :
float32
代码#2:
# Python program explaining
# numpy.find_common_type() function
# importing numpy as geek
import numpy as geek
gfg = geek.find_common_type([geek.float32], [complex])
print (gfg)
输出 :
complex128