diff --git a/python/pyarrow/table.pxi b/python/pyarrow/table.pxi index 30fff040fc37..c92ca6d5b7f0 100644 --- a/python/pyarrow/table.pxi +++ b/python/pyarrow/table.pxi @@ -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 @@ -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): diff --git a/python/pyarrow/tests/test_table.py b/python/pyarrow/tests/test_table.py index 0fefabf02abe..1c80c3aa6117 100644 --- a/python/pyarrow/tests/test_table.py +++ b/python/pyarrow/tests/test_table.py @@ -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(),