pyarrow.csv.CSVStreamingReader#

class pyarrow.csv.CSVStreamingReader#

Bases: RecordBatchReader

An object that reads record batches incrementally from a CSV file.

Should not be instantiated directly by user code.

__init__(*args, **kwargs)#

方法

__init__(*args, **kwargs)

cast(self, target_schema)

用一个在提取时延迟转换每个批次的读取器来包装此读取器。

close(self)

释放与读取器关联的所有资源。

from_batches(Schema schema, batches)

从批次的可迭代对象创建 RecordBatchReader。

from_stream(data[, schema])

从 Arrow 兼容的流对象创建 RecordBatchReader。

iter_batches_with_custom_metadata(self)

迭代流中的记录批次及其自定义元数据。

read_all(self)

读取所有记录批次并作为 pyarrow.Table 返回。

read_next_batch(self)

从流中读取下一个 RecordBatch。

read_next_batch_with_custom_metadata(self)

从流中读取下一个 RecordBatch 及其自定义元数据。

read_pandas(self, **options)

将流内容读取为 pandas.DataFrame。

属性

cast(self, target_schema)#

用一个在提取时延迟转换每个批次的读取器来包装此读取器。目前仅实现了向 target_schema 的安全转换。

参数:
target_schemaSchema

要转换到的 Schema,字段的名称和顺序必须匹配。

返回:
RecordBatchReader
close(self)#

释放与读取器关联的所有资源。

static from_batches(Schema schema, batches)#

从批次的可迭代对象创建 RecordBatchReader。

参数:
schemaSchema

记录批次的共享模式

batchesIterable[RecordBatch]

此读取器将返回的批次。

返回:
readerRecordBatchReader
static from_stream(data, schema=None)#

从 Arrow 兼容的流对象创建 RecordBatchReader。

This accepts objects implementing the Arrow PyCapsule Protocol for streams, i.e. objects that have a __arrow_c_stream__ method.

参数:
dataArrow 兼容的 stream 对象

任何实现了 Arrow PyCapsule 流协议的对象。

schemaSchema, 默认值 None

如果流对象支持,则为流应转换到的模式。

返回:
RecordBatchReader
iter_batches_with_custom_metadata(self)#

迭代流中的记录批次及其自定义元数据。

生成:
RecordBatchWithMetadata
read_all(self)#

读取所有记录批次并作为 pyarrow.Table 返回。

返回:
read_next_batch(self)#

从流中读取下一个 RecordBatch。

返回:
RecordBatch
引发:
StopIteration

位于流末尾时。

read_next_batch_with_custom_metadata(self)#

从流中读取下一个 RecordBatch 及其自定义元数据。

返回:
batchRecordBatch
custom_metadataKeyValueMetadata
引发:
StopIteration

位于流末尾时。

read_pandas(self, **options)#

将流内容读取为 pandas.DataFrame。

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

参数:
**options

Arguments to forward to Table.to_pandas().

返回:
dfpandas.DataFrame
schema#