
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Return True if first argument is a typecode lower/equal in type hierarchy in Python
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
- Related Articles
- Determine if the type in the first argument is a subclass of second in Python
- Compare and return True if two string arrays are equal in Numpy
- Return True if all entries of two arrays are equal in Numpy
- Compare and return True if a Numpy array is greater than equal to another
- Compare and return True if a Numpy array is less than equal to another
- Return True if cast between scalar and data type can occur according to the casting rule in Python
- Return True if a document exists in MongoDB?
- Return True if two Numpy arrays are element-wise equal within a tolerance
- Return TRUE if the first string starts with a specific second string JavaScript
- Return the angle of the complex argument in Python
- Return True if cast between array scalar and data type can occur according to the casting rule in Python
- Can we overload a method based on different return type but same argument type and number, in java?
- Compare and return True if two string Numpy arrays are not equal
- Get the TypeCode for value type Char in C#
- Get the TypeCode for value type Decimal in C#

Advertisements