Friday, September 5, 2025
HomeLanguagesnumpy.common_type() function – Python

numpy.common_type() function – Python

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 :




# Python program explaining
# numpy.common_type() function
          
# importing numpy as geek 
import numpy as geek 
      
gfg = geek.common_type(geek.arange(2, dtype = geek.float32))
    
print (gfg)


Output :

class 'numpy.float32'

 
Code #2 :




# Python program explaining
# numpy.common_type() function
          
# importing numpy as geek 
import numpy as geek 
      
gfg = geek.common_type(geek.arange(2, dtype = geek.float32), geek.arange(2))
    
print (gfg)


Output :

class 'numpy.float64'
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