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


##########
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:
   +1 on code deduplication, I'll give it a shot. The only differences 
currently are the parameters passed into `pandas_api.series(arr)`. Arrays want 
copy=False, and ChunkedArray has enough info to add name=self._name. 



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