numpy.common_type() function – Python
Last Updated :
18 Jun, 2020
numpy.common_type()
function return a scalar type which is common to the input arrays.
Syntax : numpy.common_type(arrays)
Parameters :
array1, array2, …. : [ndarrays] Input arrays.
Return : [dtype] Return the data type which is common to the input arrays.
Code #1 :
import numpy as geek
gfg = geek.common_type(geek.arange( 2 , dtype = geek.float32))
print (gfg)
|
Output :
class 'numpy.float32'
Code #2 :
import numpy as geek
gfg = geek.common_type(geek.arange( 2 , dtype = geek.float32), geek.arange( 2 ))
print (gfg)
|
Output :
class 'numpy.float64'
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...