Skip to content
Related Articles

Related Articles

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 :

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output :



float64

 
Code #2 :

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output :

complex128

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :