danepitkin commented on code in PR #36242:
URL: https://github.com/apache/arrow/pull/36242#discussion_r1239024807


##########
python/pyarrow/table.pxi:
##########
@@ -1487,6 +1487,16 @@ cdef class _Tabular(_PandasConvertible):
 
         return _PyArrowDataFrame(self, nan_as_null, allow_copy)
 
+    def __array__(self, dtype=None):
+        column_arrays = [
+            np.asarray(self.column(i), dtype=dtype) for i in 
range(self.num_columns)
+        ]
+        if column_arrays:
+            arr = np.stack(column_arrays, axis=1)
+        else:
+            arr = np.empty((self.num_rows, 0), dtype=dtype)

Review Comment:
   Just out of curiosity, is it possible to have `self.num_rows > 0` in this 
case? I would imagine that if there are no columns then there are no rows.



##########
python/pyarrow/table.pxi:
##########
@@ -1487,6 +1487,16 @@ cdef class _Tabular(_PandasConvertible):
 
         return _PyArrowDataFrame(self, nan_as_null, allow_copy)
 
+    def __array__(self, dtype=None):

Review Comment:
   nit: should we maintain alphabetization of methods (ignoring the `__init__` 
method)?



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