pyarrow.DataType#

class pyarrow.DataType#

基类: _Weakrefable

所有 Arrow 数据类型的基类。

每种数据类型都是此类的一个实例

示例

int64 类型的实例

>>> import pyarrow as pa
>>> pa.int64()
DataType(int64)
__init__(*args, **kwargs)#

方法

__init__(*args, **kwargs)

equals(self, other, *[, check_metadata])

如果类型与传入的值等价,则返回 True。

field(self, i)

to_pandas_dtype(self)

返回等效的 NumPy / Pandas dtype。

属性

bit_width (位宽)

固定宽度类型的位宽。

byte_width (字节宽)

固定宽度类型的字节宽。

has_variadic_buffers (是否有可变缓冲区)

如果为 True,则预期的缓冲区数量仅受 num_buffers 的下界限制。

id

num_buffers (缓冲区数量)

构建数组类型(不包括子项)所需的缓冲区数量。

num_fields (字段数量)

子字段的数量。

bit_width#

固定宽度类型的位宽。

示例

>>> import pyarrow as pa
>>> pa.int64()
DataType(int64)
>>> pa.int64().bit_width
64
byte_width#

固定宽度类型的字节宽。

示例

>>> import pyarrow as pa
>>> pa.int64()
DataType(int64)
>>> pa.int64().byte_width
8
equals(self, other, *, check_metadata=False)#

如果类型与传入的值等价,则返回 True。

参数:
otherDataType 或可转换为 DataTypestr
check_metadatabool

是否也应检查嵌套字段元数据的相等性。

返回:
is_equalbool

示例

>>> import pyarrow as pa
>>> pa.int64().equals(pa.string())
False
>>> pa.int64().equals(pa.int64())
True
field(self, i) Field#
参数:
iint
返回:
pyarrow.Field
has_variadic_buffers#

如果为 True,则预期的缓冲区数量仅受 num_buffers 的下界限制。

示例

>>> import pyarrow as pa
>>> pa.int64().has_variadic_buffers
False
>>> pa.string_view().has_variadic_buffers
True
id#
num_buffers#

构建数组类型(不包括子项)所需的缓冲区数量。

示例

>>> import pyarrow as pa
>>> pa.int64().num_buffers
2
>>> pa.string().num_buffers
3
num_fields#

子字段的数量。

示例

>>> import pyarrow as pa
>>> pa.int64()
DataType(int64)
>>> pa.int64().num_fields
0
>>> pa.list_(pa.string())
ListType(list<item: string>)
>>> pa.list_(pa.string()).num_fields
1
>>> struct = pa.struct({'x': pa.int32(), 'y': pa.string()})
>>> struct.num_fields
2
to_pandas_dtype(self)#

返回等效的 NumPy / Pandas dtype。

示例

>>> import pyarrow as pa
>>> pa.int64().to_pandas_dtype()
<class 'numpy.int64'>