jorisvandenbossche commented on code in PR #36314:
URL: https://github.com/apache/arrow/pull/36314#discussion_r1247512173


##########
python/pyarrow/array.pxi:
##########
@@ -1475,6 +1475,22 @@ cdef class Array(_PandasConvertible):
         return self.take(indices)
 
     def _to_pandas(self, options, types_mapper=None, **kwargs):
+        pandas_dtype = None
+
+        if types_mapper:
+            pandas_dtype = types_mapper(self.type)
+        elif self.type.id == _Type_EXTENSION:
+            try:
+                pandas_dtype = self.type.to_pandas_dtype()
+            except NotImplementedError:
+                pass
+
+        # Only call __from_arrow__ for Arrow extension types or when explicitly
+        # overridden via types_mapper
+        if hasattr(pandas_dtype, '__from_arrow__'):
+            arr = pandas_dtype.__from_arrow__(self)
+            return pandas_api.series(arr, copy=False)

Review Comment:
   > I thought maybe it was left out on purpose since the memory is not 
guaranteed to be contiguous.
   
   ChunkedArray itself can indeed consist of multiple chunks, but at the moment 
we reach the `pandas_api.series(arr, copy=False)` code, we already converted 
the ChunkedArray to a single contiguous numpy array (or pandas ExtensionArray). 
And anyway, this `copy=False` is mostly to indicate to pandas they don't need 
to do an extra copy (https://github.com/apache/arrow/pull/34593).



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to