You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@arrow.apache.org by "quentin lhoest (Jira)" <ji...@apache.org> on 2020/08/18 15:56:00 UTC

[jira] [Created] (ARROW-9787) pa.array.to_pandas(types_mapper=...) doesn't change the dtype

quentin lhoest created ARROW-9787:
-------------------------------------

             Summary: pa.array.to_pandas(types_mapper=...) doesn't change the dtype
                 Key: ARROW-9787
                 URL: https://issues.apache.org/jira/browse/ARROW-9787
             Project: Apache Arrow
          Issue Type: Bug
          Components: Python
    Affects Versions: 1.0.0
            Reporter: quentin lhoest


Hello !

It looks like it is possible to map arrow types to pandas types using the `types_mapper` argument in `to_pandas`. However it seems to work only for `pa.Table.to_pandas` and not `pa.array.to_pandas`.

Example to reproduce:

```
import pyarrow as pa
import pandas as pd

def types_mapper(dtype):
    print("Looking at dtype")
    if dtype == pa.int64():
        print("Changing dtype")
        return pd.Int32Dtype()

arr = pa.array([1,2,3], pa.int64())

print(pa.Table.from_arrays([arr], names=["col"]).to_pandas(types_mapper=types_mapper).col.dtype)
# Prints:
# Looking at dtype
# Changing dtype
# Int32

print(arr.to_pandas(types_mapper=types_mapper).dtype)
# Prints:
# int64

```




--
This message was sent by Atlassian Jira
(v8.3.4#803005)