ni-todo-spot opened a new issue, #13353:
URL: https://github.com/apache/arrow/issues/13353

   Hey All,
   
   I was wondering what is the most elegant & efficient way of casting a 
decimal column of a table into a float type, when converting a table into a 
pandas dataframe?
   
   In the code I'm working on, I got to a situation which a `Table` instance 
has a column of a `decimal128(6, 5)` data type.
   I'd like to convert that into a `float` data type.
   
   I tried the following:
   (see 
[this](https://arrow.apache.org/docs/python/api/datatypes.html#type-checking) & 
[this](https://arrow.apache.org/docs/python/pandas.html#nullable-types) for 
reference)
   
   ```python
   import pandas as pd
   import pyarrow as pa
   
   def converter(data_type):
       if pa.types.is_decimal(data_type):
           return pd.Float64Dtype()
       return None
   
   table = ... # contains a decimal column
   df = table.to_pandas(types_mapper=converter)
   ```
   
   But when I tried it I got the following error: `TypeError: Expected array of 
Float64 type, got decimal128(6, 5) instead`
   
   Can anyone please suggest a better way to cast such column into a float data 
type?
   
   Thanks in advance!


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

Reply via email to