jorisvandenbossche commented on a change in pull request #12010:
URL: https://github.com/apache/arrow/pull/12010#discussion_r774453135



##########
File path: python/pyarrow/table.pxi
##########
@@ -671,13 +671,55 @@ cdef class RecordBatch(_PandasConvertible):
         Returns
         -------
         RecordBatch
+
+        Examples
+        --------
+        >>> import pyarrow as pa
+        >>> pydict = {'int': [1, 2], 'str': ['a', 'b']}
+        >>> pa.RecordBatch.from_pydict(pydict)
+        pyarrow.RecordBatch
+        int: int64
+        str: string
         """
 
         return _from_pydict(cls=RecordBatch,
                             mapping=mapping,
                             schema=schema,
                             metadata=metadata)
 
+    @staticmethod
+    def from_pylist(mapping, schema=None, metadata=None):
+        """
+        Construct a RecordBatch from Arrow arrays or columns.
+
+        Parameters
+        ----------
+        mapping : list of dicts or Mappings
+            A mapping of strings to Arrays or Python lists.
+        schema : Schema, default None
+            If not passed, will be inferred from the Mapping values.
+        metadata : dict or Mapping, default None
+            Optional metadata for the schema (if inferred).
+
+        Returns
+        -------
+        RecordBatch
+
+        Examples
+        --------
+        >>> import pyarrow as pa
+        >>> pylist = [{'int': [1, 2]}, {'str': ['a', 'b']}]
+        >>> pa.RecordBatch.from_pylist(pylist)

Review comment:
       This is the same example as for `from_pydict`, that's maybe a copy paste 
leftover?

##########
File path: python/pyarrow/table.pxi
##########
@@ -671,13 +671,55 @@ cdef class RecordBatch(_PandasConvertible):
         Returns
         -------
         RecordBatch
+
+        Examples
+        --------
+        >>> import pyarrow as pa
+        >>> pydict = {'int': [1, 2], 'str': ['a', 'b']}
+        >>> pa.RecordBatch.from_pydict(pydict)
+        pyarrow.RecordBatch
+        int: int64
+        str: string
         """
 
         return _from_pydict(cls=RecordBatch,
                             mapping=mapping,
                             schema=schema,
                             metadata=metadata)
 
+    @staticmethod
+    def from_pylist(mapping, schema=None, metadata=None):
+        """
+        Construct a RecordBatch from Arrow arrays or columns.
+
+        Parameters
+        ----------
+        mapping : list of dicts or Mappings
+            A mapping of strings to Arrays or Python lists.
+        schema : Schema, default None
+            If not passed, will be inferred from the Mapping values.
+        metadata : dict or Mapping, default None
+            Optional metadata for the schema (if inferred).
+
+        Returns
+        -------
+        RecordBatch
+
+        Examples
+        --------
+        >>> import pyarrow as pa
+        >>> pylist = [{'int': [1, 2]}, {'str': ['a', 'b']}]
+        >>> pa.RecordBatch.from_pylist(pylist)

Review comment:
       Actually, I see the difference now (this is a list of separate dict per 
column instead of a single dict). But, I think this is actually not exactly 
what we want here. Or at least, my expectation was to be able to handle an 
input like:
   
   ```
   pylist = [{'int': 1, 'str'; 'a'}, {'int': 2, 'str': 'b'}]
   ```
   
   So also a list of dict, but differently organized (one dict per row, instead 
of one dict per column)




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to