pyarrow.csv.CSVStreamingReader#
- class pyarrow.csv.CSVStreamingReader#
Bases:
RecordBatchReaderAn 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。
迭代流中的记录批次及其自定义元数据。
read_all(self)读取所有记录批次并作为 pyarrow.Table 返回。
read_next_batch(self)从流中读取下一个 RecordBatch。
从流中读取下一个 RecordBatch 及其自定义元数据。
read_pandas(self, **options)将流内容读取为 pandas.DataFrame。
属性
- cast(self, target_schema)#
用一个在提取时延迟转换每个批次的读取器来包装此读取器。目前仅实现了向 target_schema 的安全转换。
- 参数:
- target_schema
Schema 要转换到的 Schema,字段的名称和顺序必须匹配。
- target_schema
- 返回:
- RecordBatchReader
- close(self)#
释放与读取器关联的所有资源。
- static from_batches(Schema schema, batches)#
从批次的可迭代对象创建 RecordBatchReader。
- 参数:
- schema
Schema 记录批次的共享模式
- batches
Iterable[RecordBatch] 此读取器将返回的批次。
- schema
- 返回:
- 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.
- iter_batches_with_custom_metadata(self)#
迭代流中的记录批次及其自定义元数据。
- 生成:
RecordBatchWithMetadata
- read_next_batch(self)#
从流中读取下一个 RecordBatch。
- 返回:
- 引发:
- StopIteration
位于流末尾时。
- read_next_batch_with_custom_metadata(self)#
从流中读取下一个 RecordBatch 及其自定义元数据。
- 返回:
- batch
RecordBatch - custom_metadata
KeyValueMetadata
- batch
- 引发:
- StopIteration
位于流末尾时。
- read_pandas(self, **options)#
将流内容读取为 pandas.DataFrame。
将所有记录批次读取为 pyarrow.Table,然后使用 Table.to_pandas 将其转换为 pandas.DataFrame。
- 参数:
- **options
Arguments to forward to
Table.to_pandas().
- 返回:
- schema#