NumPy Data type: obj2sctype() function
numpy.obj2sctype() function
The numpy.obj2sctype() function returns the scalar dtype or NumPy equivalent of Python type of an object.
Version: 1.15.0
Syntax:
numpy.obj2sctype(rep, default=None)
Parameter:
Name | Description | Required / Optional |
---|---|---|
rep : any | The object of which the type is returned. | Required |
default | If given, this is returned for objects whose types can not be determined. If not given, None is returned for those objects. | Optional |
Return value:
dtype : dtype or Python type - The data type of rep.
Example-1: numpy.obj2sctype() function
>>> import numpy as np
>>> np.obj2sctype(np.int32)
<class 'numpy.int32'>
>>> np.obj2sctype(np.array([1., 2.]))
<class 'numpy.float64'>
>>> np.obj2sctype(np.array([1.j]))
<class 'numpy.complex128'>
>>> np.obj2sctype(dict)
<class 'numpy.object_'>
>>> np.obj2sctype(1, default=list)
<class 'list'>
Python - NumPy Code Editor:
Previous:
common_type()
Next:
Crreating data types dtype()
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework