numpy.promote_types() function – Python
Last Updated :
18 Jun, 2020
numpy.promote_types()
function is a symmetric function which returns the data type with the smallest size and smallest scalar kind to which both type1 and type2 may be safely cast. The returned data type is always in native byte order.
Syntax : numpy.promote_types(type1, type2)
Parameters :
type1 : [dtype or dtype specifier] First data type.
type2 : [dtype or dtype specifier] Second data type.
Return : [dtype] Return the promoted data type.
Code #1 :
import numpy as geek
gfg = geek.promote_types( 'f4' , 'i8' )
print (gfg)
|
Output :
float64
Code #2 :
import numpy as geek
gfg = geek.promote_types( '>i8' , '<c8' )
print (gfg)
|
Output :
complex128
Share your thoughts in the comments
Please Login to comment...