使用NumPy的loadtxt()和genfromtxt的'dtype'有哪些可用的数据类型?

rya*_*lon 42 python numpy

有哪些可用的numpy.loadtxtnumpy.genfromtxt用于导入具有不同数据类型的表数据,有哪些可用的缩写(例如i32表示整数)?

这篇文章演示了条件的使用,如果有人可能会详细说明,我很好奇.

hpa*_*ulj 46

除此之外np.sctypeDict,还有以下变量:

In [141]: np.typecodes
Out[141]: 
{'All': '?bhilqpBHILQPefdgFDGSUVOMm',
 'AllFloat': 'efdgFDG',
 'AllInteger': 'bBhHiIlLqQpP',
 'Character': 'c',
 'Complex': 'FDG',
 'Datetime': 'Mm',
 'Float': 'efdg',
 'Integer': 'bhilqp',
 'UnsignedInteger': 'BHILQP'}

In [143]: np.sctypes
Out[143]: 
{'complex': [numpy.complex64, numpy.complex128, numpy.complex192],
 'float': [numpy.float16, numpy.float32, numpy.float64, numpy.float96],
 'int': [numpy.int8, numpy.int16, numpy.int32, numpy.int32, numpy.int64],
 'others': [bool, object, str, unicode, numpy.void],
 'uint': [numpy.uint8, numpy.uint16, numpy.uint32, numpy.uint32, numpy.uint64]}
Run Code Online (Sandbox Code Playgroud)


Jon*_*nts 7

关于以下内容的通用信息dtypes:http://docs.scipy.org/doc/numpy/reference/arrays.dtypes.html

来自http://docs.scipy.org/doc/numpy/reference/arrays.scalars.html#arrays-scalars-built-in

在NumPy中,有24种新的基本Python类型来描述不同类型的标量.这些类型描述符主要基于CPython编写的C语言中可用的类型,其他几种类型与Python的类型兼容.

而我没有意识到的是:

类似C的名称与字符代码相关联,如表中所示.但是,不鼓励使用字符代码.

我怀疑numpy代码/文档基础是否会很快发生,所以我想这就是全部!