pyarrow.ipc.RecordBatchFileReader#

class pyarrow.ipc.RecordBatchFileReader(source, footer_offset=None, *, options=None, memory_pool=None)[source]#

基类: _RecordBatchFileReader

用于从 Arrow 二进制文件格式读取 Arrow 记录批数据的类。

参数:
source字节/类缓冲区对象, pyarrow.NativeFile, 或类文件 Python 对象

可以是内存中的缓冲区,也可以是可读的文件对象。如果要使用内存映射,请使用 MemoryMappedFile 作为 source。

footer_offsetint, 默认值 None

如果文件嵌入到某个更大的文件中,则此参数表示文件数据末尾的字节偏移量。

optionspyarrow.ipc.IpcReadOptions

IPC 序列化的选项。如果为 None,将使用默认值。

memory_poolMemoryPool, 默认 None

如果为 None,则使用默认内存池。

__init__(source, footer_offset=None, *, options=None, memory_pool=None)[source]#

方法

__init__(source[, footer_offset, options, ...])

get_batch(self, int i)

读取具有给定索引的记录批。

get_batch_with_custom_metadata(self, int i)

读取具有给定索引的记录批及其自定义元数据。

get_record_batch(self, int i)

读取具有给定索引的记录批。

read_all(self)

将所有记录批读取为 pyarrow.Table。

read_pandas(self, **options)

将流内容读取为 pandas.DataFrame。

属性

metadata

文件级自定义元数据,为字典形式,其中键和值都类似于字节。

num_record_batches

IPC 文件中的记录批数量。

模式

stats

当前的 IPC 读取统计信息。

get_batch(self, int i)#

读取具有给定索引的记录批。

参数:
iint

记录批在 IPC 文件中的索引。

返回:
batchRecordBatch
get_batch_with_custom_metadata(self, int i)#

读取具有给定索引的记录批及其自定义元数据。

参数:
iint

记录批在 IPC 文件中的索引。

返回:
batchRecordBatch
custom_metadataKeyValueMetadata
get_record_batch(self, int i)#

读取具有给定索引的记录批。

参数:
iint

记录批在 IPC 文件中的索引。

返回:
batchRecordBatch
metadata#

文件级自定义元数据,为字典形式,其中键和值都类似于字节。这类元数据可以通过 ipc.new_file(..., metadata=...) 写入。

num_record_batches#

IPC 文件中的记录批数量。

read_all(self)#

将所有记录批读取为 pyarrow.Table。

read_pandas(self, **options)#

将流内容读取为 pandas.DataFrame。

将所有记录批次读取为 pyarrow.Table,然后使用 Table.to_pandas 将其转换为 pandas.DataFrame。

参数:
**options

要转发给 Table.to_pandas() 的参数。

返回:
dfpandas.DataFrame
schema#
stats#

当前的 IPC 读取统计信息。