Friday, September 5, 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
32264 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6634 POSTS0 COMMENTS
Nicole Veronica
11801 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11863 POSTS0 COMMENTS
Shaida Kate Naidoo
6750 POSTS0 COMMENTS
Ted Musemwa
7025 POSTS0 COMMENTS
Thapelo Manthata
6701 POSTS0 COMMENTS
Umr Jansen
6718 POSTS0 COMMENTS