numpy.obj2sctype() function – Python
Last Updated :
18 Jun, 2020
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 :
import numpy as geek
gfg = geek.obj2sctype(geek.float64)
print (gfg)
|
Output :
class 'numpy.float64'
Code #2 :
import numpy as geek
gfg = geek.obj2sctype(geek.array([ 1.j ]))
print (gfg)
|
Output :
class 'numpy.complex128'
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...