amol- commented on a change in pull request #12010:
URL: https://github.com/apache/arrow/pull/12010#discussion_r773251719



##########
File path: python/pyarrow/table.pxi
##########
@@ -1016,6 +1058,21 @@ cdef class RecordBatch(_PandasConvertible):
             entries.append((name, column))
         return ordered_dict(entries)
 
+    def to_pylist(self):
+        """
+        Convert the RecordBatch to a list of dictionaries.
+
+        Returns
+        -------
+        list
+        """
+        entries = []
+        for i in range(self.batch.num_columns()):
+            name = bytes(self.batch.column_name(i)).decode('utf8')
+            column = self[i].to_pylist()
+            entries.append({name: column})

Review comment:
       Given this might involve thousand of columns I think there is value in 
building it as a list comprehension, it's generally faster than multiple 
appends.




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