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


##########
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:
   Given that this code is both here and in the ChunkedArray version, and both 
methods also end up calling `_array_like_to_pandas`, we can maybe move this 
logic there to avoid duplicating it.



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