-
numpy.sctype2char(sctype)
[source] -
Return the string representation of a scalar dtype.
Parameters: 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.Returns: 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.See also
Examples
1234567>>>
for
sctype
in
[np.int32, np.
float
, np.
complex
, np.string_, np.ndarray]:
...
print
(np.sctype2char(sctype))
l
d
D
S
O
12345>>> x
=
np.array([
1.
,
2
-
1.j
])
>>> np.sctype2char(x)
'D'
>>> np.sctype2char(
list
)
'O'
numpy.sctype2char()

2025-01-10 15:47:30
Please login to continue.