Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions python/pyarrow/table.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -3428,13 +3428,13 @@ cdef class RecordBatch(_Tabular):
return cls.from_arrays(arrays, schema=schema)

@staticmethod
def from_arrays(list arrays, names=None, schema=None, metadata=None):
def from_arrays(arrays, names=None, schema=None, metadata=None):
"""
Construct a RecordBatch from multiple pyarrow.Arrays

Parameters
----------
arrays : list of pyarrow.Array
arrays : list or tuple of pyarrow.Array
One for each field in RecordBatch
names : list of str, optional
Names for the batch fields. If not passed, schema must be passed
Expand Down Expand Up @@ -6080,7 +6080,7 @@ def record_batch(data, names=None, schema=None, metadata=None):
return RecordBatch.from_pandas(data, schema=schema)

else:
raise TypeError("Expected pandas DataFrame or list of arrays")
raise TypeError("Expected pandas DataFrame or list/tuple of arrays")


def table(data, names=None, schema=None, metadata=None, nthreads=None):
Expand Down
8 changes: 8 additions & 0 deletions python/pyarrow/tests/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -2770,6 +2770,14 @@ def test_table_repr_to_string_ellipsis():
c1: [[10,20,30,40,10,...,40,10,20,30,40]]"""


def test_record_batch_from_tuple_of_arrays():
# GH-55418: record_batch must accept a tuple of arrays like a list
batch = pa.record_batch((pa.array([1]),), names=["a"])
assert batch.num_columns == 1
assert batch.column(0).to_pylist() == [1]
assert batch == pa.record_batch([pa.array([1])], names=["a"])


def test_record_batch_repr_to_string():
# Schema passed explicitly
schema = pa.schema([pa.field('c0', pa.int16(),
Expand Down
Loading