To return True if first argument is a typecode lower/equal in type hierarchy, use the numpy.issubdtype() method in Python Numpy. The parameters are the dtype or object coercible to one
Steps
At first, import the required library −
import numpy as np
Using the issubdtype() method in Numpy −
print("Result...",np.issubdtype(np.float64, np.float32)) print("Result...",np.issubdtype(np.float64, np.floating)) print("Result...",np.issubdtype(np.float32, np.floating)) print("Result...",np.issubdtype('i4', np.signedinteger)) print("Result...",np.issubdtype('i8', np.signedinteger)) print("Result...",np.issubdtype(np.int32, np.integer))
Example
import numpy as np # To return True if first argument is a typecode lower/equal in type hierarchy, use the numpy.issubdtype() method in Python Numpy. # The parameters are the dtype or object coercible to one print("Using the issubdtype() method in Numpy\n") print("Result...",np.issubdtype(np.float64, np.float32)) print("Result...",np.issubdtype(np.float64, np.floating)) print("Result...",np.issubdtype(np.float32, np.floating)) print("Result...",np.issubdtype('i4', np.signedinteger)) print("Result...",np.issubdtype('i8', np.signedinteger)) print("Result...",np.issubdtype(np.int32, np.integer))
Output
Using the issubdtype() method in Numpy Result... False Result... True Result... True Result... True Result... True Result... True