You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "jorisvandenbossche (via GitHub)" <gi...@apache.org> on 2023/06/08 15:53:46 UTC

[GitHub] [arrow] jorisvandenbossche commented on issue #35802: [Python] Support pandas dtype_backend=pyarrow in to_pandas

jorisvandenbossche commented on issue #35802:
URL: https://github.com/apache/arrow/issues/35802#issuecomment-1582885252

   FWIW, I think you can already relatively easily achieve the desired result with using the `types_mapper` keyword, like `table.to_pandas(types_mapper=pd.ArrowDtype)`. For example:
   
   ```
   In [15]: table = pa.table({'a': [1, 2, 3], 'b': ["a", "b", "c"]})
   
   In [16]: df = table.to_pandas(types_mapper=pd.ArrowDtype)
   
   In [17]: df
   Out[17]: 
      a  b
   0  1  a
   1  2  b
   2  3  c
   
   In [18]: df.dtypes
   Out[18]: 
   a     int64[pyarrow]
   b    string[pyarrow]
   dtype: object
   ```
   


-- 
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-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org