Friday, October 10, 2025
HomeLanguagesnumpy.promote_types() function – Python

numpy.promote_types() function – Python

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 :




# Python program explaining
# numpy.promote_types() function
          
# importing numpy as geek 
import numpy as geek 
      
gfg = geek.promote_types('f4', 'i8')
    
print (gfg)


Output :

float64

 
Code #2 :




# Python program explaining
# numpy.promote_types() function
          
# importing numpy as geek 
import numpy as geek 
      
gfg = geek.promote_types('>i8', '<c8')
    
print (gfg)


Output :

complex128
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32349 POSTS0 COMMENTS
Milvus
87 POSTS0 COMMENTS
Nango Kala
6715 POSTS0 COMMENTS
Nicole Veronica
11878 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11941 POSTS0 COMMENTS
Shaida Kate Naidoo
6837 POSTS0 COMMENTS
Ted Musemwa
7097 POSTS0 COMMENTS
Thapelo Manthata
6792 POSTS0 COMMENTS
Umr Jansen
6791 POSTS0 COMMENTS