Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

NumPy Data type: sctype2char() function

numpy.sctype2char() function

The sctype2char() function is used to get the string representation of a scalar dtype.

Version: 1.15.0

Syntax:

numpy.sctype2char(sctype)

Parameter:

Name Description Required /
Optional
sctype : scalar dtype or object If a scalar dtype, the corresponding string character is returned. If an object, sctype2char tries to infer its scalar type and then return the corresponding string character. Required

Return value:

typechar : str - The string character corresponding to the scalar type.

Raises:

ValueError - If sctype is an object for which the type can not be inferred.

Example: numpy.sctype2char() function

>>> import numpy as np
>>> for sctype in [np.int32, float, complex, np.string_, np.ndarray]:
	print(np.sctype2char(sctype))
	
l
d
D
S
O

Example: numpy.sctype2char() function

>>> import numpy as np
>>> a = np.array([1., 2-1.j])
>>> np.sctype2char(a)
'D'
>>> np.sctype2char(list)
'O'
>>>

Python Code Editor:

Previous: Miscellaneous typename()
Next: mintypecode()