jorisvandenbossche commented on a change in pull request #12178:
URL: https://github.com/apache/arrow/pull/12178#discussion_r798436243
##########
File path: python/pyarrow/tests/test_pandas.py
##########
@@ -4082,6 +4082,66 @@ def test_array_to_pandas():
# tm.assert_series_equal(result, expected)
+def test_to_pandas_types_mapper():
+ # https://issues.apache.org/jira/browse/ARROW-9664
+ if Version(pd.__version__) < Version("1.0.0"):
+ pytest.skip("ExtensionDtype to_pandas method missing")
+
+ data = pa.array([1, 2, 3], pa.int64())
+
+ # Test with mapper function
+ types_mapper = {pa.int64(): pd.Int64Dtype()}.get
+ result = data.to_pandas(types_mapper=types_mapper)
+ assert result.dtype == types_mapper(data.type)
+
+ # Test mapper function returning None
+ types_mapper = {pa.int64(): None}.get
+ result = data.to_pandas(types_mapper=types_mapper)
+ assert result.dtype == data.type.to_pandas_dtype()
+
+ # Test mapper function not containing the dtype
+ types_mapper = {pa.float64(): pd.Float64Dtype()}.get
+ result = data.to_pandas(types_mapper=types_mapper)
+ assert result.dtype == data.type.to_pandas_dtype()
+
+ # Test for the interval extension dtype
+ # -> ignores mapping and uses default conversion
+ types_mapper = {pa.float64(): pd.IntervalDtype()}.get
+ result = data.to_pandas(types_mapper=types_mapper)
Review comment:
So from an offline discussion: conclusion is that we can just remove
this additional test case with interval dtype, since using the storage type
would not work with pandas, and converting a plain pyarrow array to a pandas
extension dtype is already covered by the int64 case above.
--
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]