[ 
https://issues.apache.org/jira/browse/ARROW-9787?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

quentin lhoest closed ARROW-9787.
---------------------------------
    Resolution: Duplicate

> [Python] 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
>            Priority: Major
>
> 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:
> {code:python}
> 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
> {code}



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

Reply via email to