| [ Web Proxy ] |
| Viewing: https://arrow.apache.org/docs/python/generated/pyarrow.RecordBatchReader.html | [Back] [Original] |
Bases: _Weakrefable
Base class for reading stream of record batches.
Record batch readers function as iterators of record batches that also provide the schema (without the need to get any batches).
Warning
Do not call this classs constructor directly, use one of the
RecordBatchReader.from_* functions instead.
Notes
To import and export using the Arrow C stream interface, use the
_import_from_c and _export_to_c methods. However, keep in mind this
interface is intended for expert users.
Examples
>>> import pyarrow as pa
>>> schema = pa.schema([('x', pa.int64())])
>>> def iter_record_batches():
... for i in range(2):
... yield pa.RecordBatch.from_arrays([pa.array([1, 2, 3])], schema=schema)
>>> reader = pa.RecordBatchReader.from_batches(schema, iter_record_batches())
>>> print(reader.schema)
x: int64
>>> for batch in reader:
... print(batch)
pyarrow.RecordBatch
x: int64
----
x: [1,2,3]
pyarrow.RecordBatch
x: int64
----
x: [1,2,3]
Methods
|
|
|
Wrap this reader with one that casts each batch lazily as it is pulled. |
|
Release any resources associated with the reader. |
|
Create RecordBatchReader from an iterable of batches. |
|
Create RecordBatchReader from a Arrow-compatible stream object. |
Iterate over record batches from the stream along with their custom metadata. |
|
|
Read all record batches as a pyarrow.Table. |
|
Read next RecordBatch from the stream. |
Read next RecordBatch from the stream along with its custom metadata. |
|
|
Read contents of stream to a pandas.DataFrame. |
Attributes
Shared schema of the record batches in the stream. |
Wrap this reader with one that casts each batch lazily as it is pulled. Currently only a safe cast to target_schema is implemented.
SchemaSchema to cast to, the names and order of fields must match.
Release any resources associated with the reader.
Create RecordBatchReader from an iterable of batches.
SchemaThe shared schema of the record batches
Iterable[RecordBatch]The batches that this reader will return.
Create RecordBatchReader from a Arrow-compatible stream object.
This accepts objects implementing the Arrow PyCapsule Protocol for
streams, i.e. objects that have a __arrow_c_stream__ method.
Iterate over record batches from the stream along with their custom metadata.
RecordBatchWithMetadataRead next RecordBatch from the stream.
At end of stream.
Read next RecordBatch from the stream along with its custom metadata.
RecordBatchKeyValueMetadataAt end of stream.
Read contents of stream to a pandas.DataFrame.
Read all record batches as a pyarrow.Table then convert it to a pandas.DataFrame using Table.to_pandas.
Arguments to forward to Table.to_pandas().
| Web Proxy Viewer | New URL | Original Page |