
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Determine if Object is Scalar Data Type in Python
To determine whether the given object represents a scalar data-type, use the numpy.issctype() method. The method returns Boolean result of check whether rep is a scalar dtype. The first parameter is the rep. If rep is an instance of a scalar dtype, True is returned.If not, False is returned.
Steps
At first, import the required library −
import numpy as np
Using the issctype() method in Numpy −
print("Result...",np.issctype(np.int32)) print("Result...",np.issctype(np.int64)) print("Result...",np.issctype(np.dtype('str'))) print("Result...",np.issctype(100)) print("Result...",np.issctype(25.9)) print("Result...",np.issctype(np.float32(22.3)))
Example
import numpy as np # To determine whether the given object represents a scalar datatype, use the numpy.issctype() method # The method returns Boolean result of check whether rep is a scalar dtype. # The first parameter is the rep. If rep is an instance of a scalar dtype, True is returned.If not, False is returned. print("Using the issctype() method in Numpy\n") print("Result...",np.issctype(np.int32)) print("Result...",np.issctype(np.int64)) print("Result...",np.issctype(np.dtype('str'))) print("Result...",np.issctype(100)) print("Result...",np.issctype(25.9)) print("Result...",np.issctype(np.float32(22.3)))
Output
Using the issctype() method in Numpy Result... True Result... True Result... True Result... False Result... False Result... False
Advertisements