numpy.__array_namespace_info__.dtypes#
method
- __array_namespace_info__.dtypes(*, device=None, kind=None)[源代码]#
NumPy支持的数组API数据类型.
请注意,此函数仅返回由数组 API 定义的数据类型.
- 参数:
- devicestr, optional
获取数据类型的设备.对于 NumPy,只允许
'cpu'.- kindstr 或 tuple of str, optional
要返回的数据类型的种类.如果为
None,则返回所有数据类型.如果为字符串,则仅返回该种类的数据类型.如果为元组,则返回包含给定种类并集的字典.支持以下种类:'bool':布尔数据类型(即bool).'signed integer':有符号整数数据类型(即int8,int16,int32,int64).'unsigned integer':无符号整数数据类型(即uint8,uint16,uint32,uint64).'integral':整数数据类型.('signed integer', 'unsigned integer')的简写.'real floating':实值浮点数据类型(即float32,float64).'complex floating':复数浮点数据类型(即complex64,complex128).'numeric':数值数据类型.('integral', 'real floating', 'complex floating')的简写.
- 返回:
- dtypesdict
将数据类型的名称映射到相应 NumPy 数据类型的字典.
参见
示例
>>> info = np.__array_namespace_info__() >>> info.dtypes(kind='signed integer') {'int8': numpy.int8, 'int16': numpy.int16, 'int32': numpy.int32, 'int64': numpy.int64}