numpy.common_type()函数–Python
原文:https://www . geesforgeks . org/numpy-common _ type-function-python/
numpy.common_type()
函数返回输入数组中常见的标量类型。
语法: numpy.common_type(数组)
参数: array1、array2、…。:【ndarrays】输入数组。 返回:【dtype】返回输入数组共有的数据类型。
代码#1 :
# Python program explaining
# numpy.common_type() function
# importing numpy as geek
import numpy as geek
gfg = geek.common_type(geek.arange(2, dtype = geek.float32))
print (gfg)
输出:
class 'numpy.float32'
代码#2 :
# Python program explaining
# numpy.common_type() function
# importing numpy as geek
import numpy as geek
gfg = geek.common_type(geek.arange(2, dtype = geek.float32), geek.arange(2))
print (gfg)
输出:
class 'numpy.float64'