Bases: _PandasConvertible
Batch of rows of columns of equal length
Warning
Do not call this classâs constructor directly, use one of the RecordBatch.from_*
functions instead.
Examples
>>> import pyarrow as pa >>> n_legs = pa.array([2, 2, 4, 4, 5, 100]) >>> animals = pa.array(["Flamingo", "Parrot", "Dog", "Horse", "Brittle stars", "Centipede"]) >>> names = ["n_legs", "animals"]
Constructing a RecordBatch from arrays:
>>> pa.RecordBatch.from_arrays([n_legs, animals], names=names) pyarrow.RecordBatch n_legs: int64 animals: string >>> pa.RecordBatch.from_arrays([n_legs, animals], names=names).to_pandas() n_legs animals 0 2 Flamingo 1 2 Parrot 2 4 Dog 3 4 Horse 4 5 Brittle stars 5 100 Centipede
Constructing a RecordBatch from pandas DataFrame:
>>> import pandas as pd >>> df = pd.DataFrame({'year': [2020, 2022, 2021, 2022], ... 'month': [3, 5, 7, 9], ... 'day': [1, 5, 9, 13], ... 'n_legs': [2, 4, 5, 100], ... 'animals': ["Flamingo", "Horse", "Brittle stars", "Centipede"]}) >>> pa.RecordBatch.from_pandas(df) pyarrow.RecordBatch year: int64 month: int64 day: int64 n_legs: int64 animals: string >>> pa.RecordBatch.from_pandas(df).to_pandas() year month day n_legs animals 0 2020 3 1 2 Flamingo 1 2022 5 5 4 Horse 2 2021 7 9 5 Brittle stars 3 2022 9 13 100 Centipede
Constructing a RecordBatch from pylist:
>>> pylist = [{'n_legs': 2, 'animals': 'Flamingo'}, ... {'n_legs': 4, 'animals': 'Dog'}] >>> pa.RecordBatch.from_pylist(pylist).to_pandas() n_legs animals 0 2 Flamingo 1 4 Dog
You can also construct a RecordBatch using pyarrow.record_batch()
:
>>> pa.record_batch([n_legs, animals], names=names).to_pandas() n_legs animals 0 2 Flamingo 1 2 Parrot 2 4 Dog 3 4 Horse 4 5 Brittle stars 5 100 Centipede
>>> pa.record_batch(df) pyarrow.RecordBatch year: int64 month: int64 day: int64 n_legs: int64 animals: string
Methods
__init__
(*args, **kwargs)
column
(self, i)
Select single column from record batch
drop_null
(self)
Remove missing values from a RecordBatch.
equals
(self, other, bool check_metadata=False)
Check if contents of two record batches are equal.
field
(self, i)
Select a schema field by its column name or numeric index
filter
(self, mask[, null_selection_behavior])
Select rows from the record batch.
from_arrays
(list arrays[, names, schema, ...])
Construct a RecordBatch from multiple pyarrow.Arrays
from_pandas
(type cls, df, Schema schema=None)
Convert pandas.DataFrame to an Arrow RecordBatch
from_pydict
(mapping[, schema, metadata])
Construct a RecordBatch from Arrow arrays or columns.
from_pylist
(mapping[, schema, metadata])
Construct a RecordBatch from list of rows / dictionaries.
from_struct_array
(StructArray struct_array)
Construct a RecordBatch from a StructArray.
get_total_buffer_size
(self)
The sum of bytes in each buffer referenced by the record batch
replace_schema_metadata
(self[, metadata])
Create shallow copy of record batch by replacing schema key-value metadata with the indicated new metadata (which may be None, which deletes any existing metadata
serialize
(self[, memory_pool])
Write RecordBatch to Buffer as encapsulated IPC message.
slice
(self[, offset, length])
Compute zero-copy slice of this RecordBatch
take
(self, indices)
Select rows from the record batch.
to_pandas
(self[, memory_pool, categories, ...])
Convert to a pandas-compatible NumPy array or DataFrame, as appropriate
to_pydict
(self)
Convert the RecordBatch to a dict or OrderedDict.
to_pylist
(self)
Convert the RecordBatch to a list of rows / dictionaries.
to_string
(self[, show_metadata])
validate
(self, *[, full])
Perform validation checks.
Attributes
List of all columns in numerical order
Total number of bytes consumed by the elements of the record batch.
Number of columns
Number of rows
Schema of the RecordBatch and its columns
Select single column from record batch
int
or str
The index or name of the column to retrieve.
pyarrow.Array
Examples
>>> import pyarrow as pa >>> n_legs = pa.array([2, 2, 4, 4, 5, 100]) >>> animals = pa.array(["Flamingo", "Parrot", "Dog", "Horse", "Brittle stars", "Centipede"]) >>> batch = pa.RecordBatch.from_arrays([n_legs, animals], ... names=["n_legs", "animals"]) >>> batch.column(1) <pyarrow.lib.StringArray object at ...> [ "Flamingo", "Parrot", "Dog", "Horse", "Brittle stars", "Centipede" ]
List of all columns in numerical order
list
of pyarrow.Array
Examples
>>> import pyarrow as pa >>> n_legs = pa.array([2, 2, 4, 4, 5, 100]) >>> animals = pa.array(["Flamingo", "Parrot", "Dog", "Horse", "Brittle stars", "Centipede"]) >>> batch = pa.RecordBatch.from_arrays([n_legs, animals], ... names=["n_legs", "animals"]) >>> batch.columns [<pyarrow.lib.Int64Array object at ...> [ 2, 2, 4, 4, 5, 100 ], <pyarrow.lib.StringArray object at ...> [ "Flamingo", "Parrot", "Dog", "Horse", "Brittle stars", "Centipede" ]]
Remove missing values from a RecordBatch. See pyarrow.compute.drop_null()
for full usage.
Examples
>>> import pyarrow as pa >>> n_legs = pa.array([2, 2, 4, 4, 5, 100]) >>> animals = pa.array(["Flamingo", "Parrot", "Dog", "Horse", None, "Centipede"]) >>> batch = pa.RecordBatch.from_arrays([n_legs, animals], ... names=["n_legs", "animals"]) >>> batch.to_pandas() n_legs animals 0 2 Flamingo 1 2 Parrot 2 4 Dog 3 4 Horse 4 5 None 5 100 Centipede >>> batch.drop_null().to_pandas() n_legs animals 0 2 Flamingo 1 2 Parrot 2 4 Dog 3 4 Horse 4 100 Centipede
Check if contents of two record batches are equal.
pyarrow.RecordBatch
RecordBatch to compare against.
False
Whether schema metadata equality should be checked as well.
Examples
>>> import pyarrow as pa >>> n_legs = pa.array([2, 2, 4, 4, 5, 100]) >>> animals = pa.array(["Flamingo", "Parrot", "Dog", "Horse", "Brittle stars", "Centipede"]) >>> batch = pa.RecordBatch.from_arrays([n_legs, animals], ... names=["n_legs", "animals"]) >>> batch_0 = pa.record_batch([]) >>> batch_1 = pa.RecordBatch.from_arrays([n_legs, animals], ... names=["n_legs", "animals"], ... metadata={"n_legs": "Number of legs per animal"}) >>> batch.equals(batch) True >>> batch.equals(batch_0) False >>> batch.equals(batch_1) True >>> batch.equals(batch_1, check_metadata=True) False
Select a schema field by its column name or numeric index
int
or str
The index or name of the field to retrieve
pyarrow.Field
Examples
>>> import pyarrow as pa >>> n_legs = pa.array([2, 2, 4, 4, 5, 100]) >>> animals = pa.array(["Flamingo", "Parrot", "Dog", "Horse", "Brittle stars", "Centipede"]) >>> batch = pa.RecordBatch.from_arrays([n_legs, animals], ... names=["n_legs", "animals"]) >>> batch.field(0) pyarrow.Field<n_legs: int64> >>> batch.field(1) pyarrow.Field<animals: string>
Select rows from the record batch.
See pyarrow.compute.filter()
for full usage.
Array
or array-like
The boolean mask to filter the record batch with.
How nulls in the mask should be handled.
RecordBatch
A record batch of the same schema, with only the rows selected by the boolean mask.
Examples
>>> import pyarrow as pa >>> n_legs = pa.array([2, 2, 4, 4, 5, 100]) >>> animals = pa.array(["Flamingo", "Parrot", "Dog", "Horse", "Brittle stars", "Centipede"]) >>> batch = pa.RecordBatch.from_arrays([n_legs, animals], ... names=["n_legs", "animals"]) >>> batch.to_pandas() n_legs animals 0 2 Flamingo 1 2 Parrot 2 4 Dog 3 4 Horse 4 5 Brittle stars 5 100 Centipede
Define a mask and select rows:
>>> mask=[True, True, False, True, False, None] >>> batch.filter(mask).to_pandas() n_legs animals 0 2 Flamingo 1 2 Parrot 2 4 Horse >>> batch.filter(mask, null_selection_behavior='emit_null').to_pandas() n_legs animals 0 2.0 Flamingo 1 2.0 Parrot 2 4.0 Horse 3 NaN None
Construct a RecordBatch from multiple pyarrow.Arrays
list
of pyarrow.Array
One for each field in RecordBatch
list
of str
, optional
Names for the batch fields. If not passed, schema must be passed
Schema
, default None
Schema for the created batch. If not passed, names must be passed
dict
or Mapping, default None
Optional metadata for the schema (if inferred).
pyarrow.RecordBatch
Examples
>>> import pyarrow as pa >>> n_legs = pa.array([2, 2, 4, 4, 5, 100]) >>> animals = pa.array(["Flamingo", "Parrot", "Dog", "Horse", "Brittle stars", "Centipede"]) >>> names = ["n_legs", "animals"]
Construct a RecordBartch from pyarrow Arrays using names:
>>> pa.RecordBatch.from_arrays([n_legs, animals], names=names) pyarrow.RecordBatch n_legs: int64 animals: string >>> pa.RecordBatch.from_arrays([n_legs, animals], names=names).to_pandas() n_legs animals 0 2 Flamingo 1 2 Parrot 2 4 Dog 3 4 Horse 4 5 Brittle stars 5 100 Centipede
Construct a RecordBartch from pyarrow Arrays using schema:
>>> my_schema = pa.schema([ ... pa.field('n_legs', pa.int64()), ... pa.field('animals', pa.string())], ... metadata={"n_legs": "Number of legs per animal"}) >>> pa.RecordBatch.from_arrays([n_legs, animals], schema=my_schema).to_pandas() n_legs animals 0 2 Flamingo 1 2 Parrot 2 4 Dog 3 4 Horse 4 5 Brittle stars 5 100 Centipede >>> pa.RecordBatch.from_arrays([n_legs, animals], schema=my_schema).schema n_legs: int64 animals: string -- schema metadata -- n_legs: 'Number of legs per animal'
Convert pandas.DataFrame to an Arrow RecordBatch
pandas.DataFrame
pyarrow.Schema
, optional
The expected schema of the RecordBatch. This can be used to indicate the type of columns if we cannot infer it automatically. If passed, the output will have exactly this schema. Columns specified in the schema that are not found in the DataFrame columns or its index will raise an error. Additional columns or index levels in the DataFrame which are not specified in the schema will be ignored.
Whether to store the index as an additional column in the resulting RecordBatch
. The default of None will store the index as a column, except for RangeIndex which is stored as metadata only. Use preserve_index=True
to force it to be stored as a column.
int
, default None
If greater than 1, convert columns to Arrow in parallel using indicated number of threads. By default, this follows pyarrow.cpu_count()
(may use up to system CPU count threads).
list
, optional
List of column to be converted. If None, use all columns.
pyarrow.RecordBatch
Examples
>>> import pandas as pd >>> df = pd.DataFrame({'year': [2020, 2022, 2021, 2022], ... 'month': [3, 5, 7, 9], ... 'day': [1, 5, 9, 13], ... 'n_legs': [2, 4, 5, 100], ... 'animals': ["Flamingo", "Horse", "Brittle stars", "Centipede"]})
Convert pandas DataFrame to RecordBatch:
>>> import pyarrow as pa >>> pa.RecordBatch.from_pandas(df) pyarrow.RecordBatch year: int64 month: int64 day: int64 n_legs: int64 animals: string
Convert pandas DataFrame to RecordBatch using schema:
>>> my_schema = pa.schema([ ... pa.field('n_legs', pa.int64()), ... pa.field('animals', pa.string())], ... metadata={"n_legs": "Number of legs per animal"}) >>> pa.RecordBatch.from_pandas(df, schema=my_schema) pyarrow.RecordBatch n_legs: int64 animals: string
Convert pandas DataFrame to RecordBatch specifying columns:
>>> pa.RecordBatch.from_pandas(df, columns=["n_legs"]) pyarrow.RecordBatch n_legs: int64
Construct a RecordBatch from Arrow arrays or columns.
dict
or Mapping
A mapping of strings to Arrays or Python lists.
Schema
, default None
If not passed, will be inferred from the Mapping values.
dict
or Mapping, default None
Optional metadata for the schema (if inferred).
RecordBatch
Examples
>>> import pyarrow as pa >>> n_legs = [2, 2, 4, 4, 5, 100] >>> animals = ["Flamingo", "Parrot", "Dog", "Horse", "Brittle stars", "Centipede"] >>> pydict = {'n_legs': n_legs, 'animals': animals}
Construct a RecordBatch from arrays:
>>> pa.RecordBatch.from_pydict(pydict) pyarrow.RecordBatch n_legs: int64 animals: string >>> pa.RecordBatch.from_pydict(pydict).to_pandas() n_legs animals 0 2 Flamingo 1 2 Parrot 2 4 Dog 3 4 Horse 4 5 Brittle stars 5 100 Centipede
Construct a RecordBatch with schema:
>>> my_schema = pa.schema([ ... pa.field('n_legs', pa.int64()), ... pa.field('animals', pa.string())], ... metadata={"n_legs": "Number of legs per animal"}) >>> pa.RecordBatch.from_pydict(pydict, schema=my_schema).schema n_legs: int64 animals: string -- schema metadata -- n_legs: 'Number of legs per animal'
Construct a RecordBatch from list of rows / dictionaries.
list
of dicts of rows
A mapping of strings to row values.
Schema
, default None
If not passed, will be inferred from the first row of the mapping values.
dict
or Mapping, default None
Optional metadata for the schema (if inferred).
RecordBatch
Examples
>>> import pyarrow as pa >>> pylist = [{'n_legs': 2, 'animals': 'Flamingo'}, ... {'n_legs': 4, 'animals': 'Dog'}] >>> pa.RecordBatch.from_pylist(pylist) pyarrow.RecordBatch n_legs: int64 animals: string >>> pa.RecordBatch.from_pylist(pylist).to_pandas() n_legs animals 0 2 Flamingo 1 4 Dog
Construct a RecordBatch with metadata:
>>> my_metadata={"n_legs": "Number of legs per animal"} >>> pa.RecordBatch.from_pylist(pylist, metadata=my_metadata).schema n_legs: int64 animals: string -- schema metadata -- n_legs: 'Number of legs per animal'
Construct a RecordBatch from a StructArray.
Each field in the StructArray will become a column in the resulting RecordBatch
.
StructArray
Array to construct the record batch from.
pyarrow.RecordBatch
Examples
>>> import pyarrow as pa >>> struct = pa.array([{'n_legs': 2, 'animals': 'Parrot'}, ... {'year': 2022, 'n_legs': 4}]) >>> pa.RecordBatch.from_struct_array(struct).to_pandas() animals n_legs year 0 Parrot 2 NaN 1 None 4 2022.0
The sum of bytes in each buffer referenced by the record batch
An array may only reference a portion of a buffer. This method will overestimate in this case and return the byte size of the entire buffer.
If a buffer is referenced multiple times then it will only be counted once.
Examples
>>> import pyarrow as pa >>> n_legs = pa.array([2, 2, 4, 4, 5, 100]) >>> animals = pa.array(["Flamingo", "Parrot", "Dog", "Horse", "Brittle stars", "Centipede"]) >>> batch = pa.RecordBatch.from_arrays([n_legs, animals], ... names=["n_legs", "animals"]) >>> batch.get_total_buffer_size() 120
Total number of bytes consumed by the elements of the record batch.
In other words, the sum of bytes from all buffer ranges referenced.
Unlike get_total_buffer_size this method will account for array offsets.
If buffers are shared between arrays then the shared portion will only be counted multiple times.
The dictionary of dictionary arrays will always be counted in their entirety even if the array only references a portion of the dictionary.
Examples
>>> import pyarrow as pa >>> n_legs = pa.array([2, 2, 4, 4, 5, 100]) >>> animals = pa.array(["Flamingo", "Parrot", "Dog", "Horse", "Brittle stars", "Centipede"]) >>> batch = pa.RecordBatch.from_arrays([n_legs, animals], ... names=["n_legs", "animals"]) >>> batch.nbytes 116
Number of columns
int
Examples
>>> import pyarrow as pa >>> n_legs = pa.array([2, 2, 4, 4, 5, 100]) >>> animals = pa.array(["Flamingo", "Parrot", "Dog", "Horse", "Brittle stars", "Centipede"]) >>> batch = pa.RecordBatch.from_arrays([n_legs, animals], ... names=["n_legs", "animals"]) >>> batch.num_columns 2
Number of rows
Due to the definition of a RecordBatch, all columns have the same number of rows.
int
Examples
>>> import pyarrow as pa >>> n_legs = pa.array([2, 2, 4, 4, 5, 100]) >>> animals = pa.array(["Flamingo", "Parrot", "Dog", "Horse", "Brittle stars", "Centipede"]) >>> batch = pa.RecordBatch.from_arrays([n_legs, animals], ... names=["n_legs", "animals"]) >>> batch.num_rows 6
Create shallow copy of record batch by replacing schema key-value metadata with the indicated new metadata (which may be None, which deletes any existing metadata
dict
, default None
RecordBatch
Examples
>>> import pyarrow as pa >>> n_legs = pa.array([2, 2, 4, 4, 5, 100])
Constructing a RecordBatch with schema and metadata:
>>> my_schema = pa.schema([ ... pa.field('n_legs', pa.int64())], ... metadata={"n_legs": "Number of legs per animal"}) >>> batch = pa.RecordBatch.from_arrays([n_legs], schema=my_schema) >>> batch.schema n_legs: int64 -- schema metadata -- n_legs: 'Number of legs per animal'
Shallow copy of a RecordBatch with deleted schema metadata:
>>> batch.replace_schema_metadata().schema n_legs: int64
Schema of the RecordBatch and its columns
pyarrow.Schema
Examples
>>> import pyarrow as pa >>> n_legs = pa.array([2, 2, 4, 4, 5, 100]) >>> animals = pa.array(["Flamingo", "Parrot", "Dog", "Horse", "Brittle stars", "Centipede"]) >>> batch = pa.RecordBatch.from_arrays([n_legs, animals], ... names=["n_legs", "animals"]) >>> batch.schema n_legs: int64 animals: string
Write RecordBatch to Buffer as encapsulated IPC message.
MemoryPool
, default None
Uses default memory pool if not specified
Buffer
Examples
>>> import pyarrow as pa >>> n_legs = pa.array([2, 2, 4, 4, 5, 100]) >>> animals = pa.array(["Flamingo", "Parrot", "Dog", "Horse", "Brittle stars", "Centipede"]) >>> batch = pa.RecordBatch.from_arrays([n_legs, animals], ... names=["n_legs", "animals"]) >>> batch.serialize() <pyarrow.lib.Buffer object at ...>
Compute zero-copy slice of this RecordBatch
int
, default 0
Offset from start of record batch to slice
int
, default None
Length of slice (default is until end of batch starting from offset)
RecordBatch
Examples
>>> import pyarrow as pa >>> n_legs = pa.array([2, 2, 4, 4, 5, 100]) >>> animals = pa.array(["Flamingo", "Parrot", "Dog", "Horse", "Brittle stars", "Centipede"]) >>> batch = pa.RecordBatch.from_arrays([n_legs, animals], ... names=["n_legs", "animals"]) >>> batch.to_pandas() n_legs animals 0 2 Flamingo 1 2 Parrot 2 4 Dog 3 4 Horse 4 5 Brittle stars 5 100 Centipede >>> batch.slice(offset=3).to_pandas() n_legs animals 0 4 Horse 1 5 Brittle stars 2 100 Centipede >>> batch.slice(length=2).to_pandas() n_legs animals 0 2 Flamingo 1 2 Parrot >>> batch.slice(offset=3, length=1).to_pandas() n_legs animals 0 4 Horse
Select rows from the record batch.
See pyarrow.compute.take()
for full usage.
Array
or array-like
The indices in the record batch whose rows will be returned.
RecordBatch
A record batch with the same schema, containing the taken rows.
Examples
>>> import pyarrow as pa >>> n_legs = pa.array([2, 2, 4, 4, 5, 100]) >>> animals = pa.array(["Flamingo", "Parrot", "Dog", "Horse", "Brittle stars", "Centipede"]) >>> batch = pa.RecordBatch.from_arrays([n_legs, animals], ... names=["n_legs", "animals"]) >>> batch.take([1,3,4]).to_pandas() n_legs animals 0 2 Parrot 1 4 Horse 2 5 Brittle stars
Convert to a pandas-compatible NumPy array or DataFrame, as appropriate
MemoryPool
, default None
Arrow MemoryPool to use for allocations. Uses the default memory pool is not passed.
False
Encode string (UTF8) and binary types to pandas.Categorical.
list
, default empty
List of fields that should be returned as pandas.Categorical. Only applies to table-like data structures.
False
Raise an ArrowException if this function call would require copying the underlying data.
False
Cast integers with nulls to objects
True
Cast dates to objects. If False, convert to datetime64[ns] dtype.
False
Cast non-nanosecond timestamps (np.datetime64) to objects. This is useful if you have timestamps that donât fit in the normal date range of nanosecond timestamps (1678 CE-2262 CE). If False, all timestamps are converted to datetime64[ns] dtype.
True
Whether to parallelize the conversion using multiple threads.
False
Do not create multiple copies Python objects when created, to save on memory use. Conversion will be slower.
False
If True, do not use the âpandasâ metadata to reconstruct the DataFrame index, if present
True
For certain data types, a cast is needed in order to store the data in a pandas DataFrame or Series (e.g. timestamps are always stored as nanoseconds in pandas). This option controls whether it is a safe cast or not.
False
If True, generate one internal âblockâ for each column when creating a pandas.DataFrame from a RecordBatch or Table. While this can temporarily reduce memory note that various pandas operations can trigger âconsolidationâ which may balloon memory use.
False
EXPERIMENTAL: If True, attempt to deallocate the originating Arrow memory while converting the Arrow object to pandas. If you use the object after calling to_pandas with this option it will crash your program.
Note that you may not see always memory usage improvements. For example, if multiple columns share an underlying allocation, memory canât be freed until all columns are converted.
None
A function mapping a pyarrow DataType to a pandas ExtensionDtype. This can be used to override the default pandas type for conversion of built-in pyarrow types or in absence of pandas_metadata in the Table schema. The function receives a pyarrow DataType and is expected to return a pandas ExtensionDtype or None
if the default conversion should be used for that type. If you have a dictionary mapping, you can pass dict.get
as function.
pandas.Series
or pandas.DataFrame
depending on type
of object
Examples
>>> import pyarrow as pa >>> import pandas as pd
Convert a Table to pandas DataFrame:
>>> table = pa.table([ ... pa.array([2, 4, 5, 100]), ... pa.array(["Flamingo", "Horse", "Brittle stars", "Centipede"]) ... ], names=['n_legs', 'animals']) >>> table.to_pandas() n_legs animals 0 2 Flamingo 1 4 Horse 2 5 Brittle stars 3 100 Centipede >>> isinstance(table.to_pandas(), pd.DataFrame) True
Convert a RecordBatch to pandas DataFrame:
>>> import pyarrow as pa >>> n_legs = pa.array([2, 4, 5, 100]) >>> animals = pa.array(["Flamingo", "Horse", "Brittle stars", "Centipede"]) >>> batch = pa.record_batch([n_legs, animals], ... names=["n_legs", "animals"]) >>> batch pyarrow.RecordBatch n_legs: int64 animals: string >>> batch.to_pandas() n_legs animals 0 2 Flamingo 1 4 Horse 2 5 Brittle stars 3 100 Centipede >>> isinstance(batch.to_pandas(), pd.DataFrame) True
Convert a Chunked Array to pandas Series:
>>> import pyarrow as pa >>> n_legs = pa.chunked_array([[2, 2, 4], [4, 5, 100]]) >>> n_legs.to_pandas() 0 2 1 2 2 4 3 4 4 5 5 100 dtype: int64 >>> isinstance(n_legs.to_pandas(), pd.Series) True
Convert the RecordBatch to a dict or OrderedDict.
dict
Examples
>>> import pyarrow as pa >>> n_legs = pa.array([2, 2, 4, 4, 5, 100]) >>> animals = pa.array(["Flamingo", "Parrot", "Dog", "Horse", "Brittle stars", "Centipede"]) >>> batch = pa.RecordBatch.from_arrays([n_legs, animals], ... names=["n_legs", "animals"]) >>> batch.to_pydict() {'n_legs': [2, 2, 4, 4, 5, 100], 'animals': ['Flamingo', 'Parrot', ..., 'Centipede']}
Convert the RecordBatch to a list of rows / dictionaries.
list
Examples
>>> import pyarrow as pa >>> n_legs = pa.array([2, 2, 4, 4, 5, 100]) >>> animals = pa.array(["Flamingo", "Parrot", "Dog", "Horse", "Brittle stars", "Centipede"]) >>> batch = pa.RecordBatch.from_arrays([n_legs, animals], ... names=["n_legs", "animals"]) >>> batch.to_pylist() [{'n_legs': 2, 'animals': 'Flamingo'}, {'n_legs': 2, ...}, {'n_legs': 100, 'animals': 'Centipede'}]
Perform validation checks. An exception is raised if validation fails.
By default only cheap validation checks are run. Pass full=True for thorough validation checks (potentially O(n)).
False
If True, run expensive checks, otherwise cheap checks only.
ArrowInvalid
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4