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



##########
File path: python/pyarrow/table.pxi
##########
@@ -2442,6 +2589,46 @@ def _from_pydict(cls, mapping, schema, metadata):
         raise TypeError('Schema must be an instance of pyarrow.Schema')
 
 
+def _from_pylist(cls, mapping, schema, metadata):
+    """
+    Construct a Table/RecordBatch from list of rows / dictionaries.
+
+    Parameters
+    ----------
+    cls : Class Table/RecordBatch
+    mapping : list of dicts of rows
+        A mapping of strings to row values.
+    schema : Schema, default None
+        If not passed, will be inferred from the first row of the
+        mapping values.
+    metadata : dict or Mapping, default None
+        Optional metadata for the schema (if inferred).
+
+    Returns
+    -------
+    Table/RecordBatch
+    """
+
+    arrays = []
+    if schema is None:
+        names = []
+        if mapping:
+            names = list(mapping[0].keys())
+        for n in names:
+            v = [i[n] if n in i else None for i in mapping]

Review comment:
       ```suggestion
               v = [row[n] if n in row else None for row in mapping]
   ```
   
   (small suggestion that makes it maybe a bit more readable; in general I 
think one-letter variables names are best avoided, except for general counting 
iterator variables like `i` in a loop (but here `i` is not a integer count))




-- 
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