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

numpy.obj2sctype() function – Python

numpy.obj2sctype() function return the scalar dtype or NumPy equivalent of Python type of an object.

Syntax : numpy.obj2sctype(rep, default = None)

Parameters :
rep : [any] The object of which the type is returned.
default : [any, optional] If given, this is returned for objects whose types can not be determined. If not given, None is returned for those objects.
Return : [dtype or Python type] Return the data type of rep.

Code #1 :




# Python program explaining
# numpy.obj2sctype() function
           
# importing numpy as geek 
import numpy as geek 
       
gfg = geek.obj2sctype(geek.float64)
     
print (gfg)


Output :

class 'numpy.float64'

 
Code #2 :




# Python program explaining
# numpy.obj2sctype() function
           
# importing numpy as geek 
import numpy as geek 
       
gfg = geek.obj2sctype(geek.array([1.j]))
     
print (gfg)


Output :

class 'numpy.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
11861 POSTS0 COMMENTS
Shaida Kate Naidoo
6750 POSTS0 COMMENTS
Ted Musemwa
7025 POSTS0 COMMENTS
Thapelo Manthata
6698 POSTS0 COMMENTS
Umr Jansen
6718 POSTS0 COMMENTS