numpy.isdtype#

numpy.isdtype(dtype, kind)[源代码]#

确定提供的 dtype 是否属于指定的数据类型 kind.

此函数仅支持内置的 NumPy 数据类型.第三方数据类型尚不支持.

参数:
dtypedtype

输入的数据类型.

kinddtype 或 str 或 dtypes/strs 的元组.

dtype 或 dtype 种类.允许的 dtype 种类有:* 'bool' : 布尔种类 * 'signed integer' : 有符号整数数据类型 * 'unsigned integer' : 无符号整数数据类型 * 'integral' : 整数数据类型 * 'real floating' : 实数浮点数据类型 * 'complex floating' : 复数浮点数据类型 * 'numeric' : 数值数据类型

返回:
outbool

参见

issubdtype

示例

>>> import numpy as np
>>> np.isdtype(np.float32, np.float64)
False
>>> np.isdtype(np.float32, "real floating")
True
>>> np.isdtype(np.complex128, ("real floating", "complex floating"))
True