[ 
https://issues.apache.org/jira/browse/ARROW-3329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17067004#comment-17067004
 ] 

Antoine Pitrou commented on ARROW-3329:
---------------------------------------

{code:python}
>>> arr = pa.array([Decimal("1234"), None], type=pa.decimal128(19,10))          
>>>                                                  
>>> arr                                                                         
>>>                                                  
<pyarrow.lib.Decimal128Array object at 0x7efbbf54f520>
[
  1234.0000000000,
  null
]
>>> arr.cast(pa.int16())                                                        
>>>                                                  
<pyarrow.lib.Int16Array object at 0x7efbc115d440>
[
  1234,
  null
]
>>> arr.cast(pa.int8())                                                         
>>>                                                  
Traceback (most recent call last):
  File "<ipython-input-6-464d8b755a6a>", line 1, in <module>
    arr.cast(pa.int8())
  File "pyarrow/array.pxi", line 674, in pyarrow.lib.Array.cast
    check_status(Cast(_context(), self.ap[0], type.sp_type,
  File "pyarrow/error.pxi", line 84, in pyarrow.lib.check_status
    raise ArrowInvalid(message)
ArrowInvalid: Integer value out of bounds

>>> arr.cast(pa.int8(), safe=False)                                             
>>>                                                  
<pyarrow.lib.Int8Array object at 0x7efbbe9d9b40>
[
  -46,
  null
]
{code}


> [Python] Error casting decimal(38, 4) to int64
> ----------------------------------------------
>
>                 Key: ARROW-3329
>                 URL: https://issues.apache.org/jira/browse/ARROW-3329
>             Project: Apache Arrow
>          Issue Type: Bug
>          Components: Python
>         Environment: Python version : 3.6.5
> Pyarrow version : 0.10.0
>            Reporter: Kavita Sheth
>            Assignee: Jacek Pliszka
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 0.17.0
>
>          Time Spent: 7h
>  Remaining Estimate: 0h
>
> Git issue LInk : https://github.com/apache/arrow/issues/2627
> I want to cast pyarrow table column from decimal(38,4) to int64.
> col.cast(pa.int64())
> Error:
>  File "pyarrow/table.pxi", line 443, in pyarrow.lib.Column.cast
>  File "pyarrow/error.pxi", line 89, in pyarrow.lib.check_status
>  pyarrow.lib.ArrowNotImplementedError: No cast implemented from decimal(38, 
> 4) to int64
> Python version : 3.6.5
>  Pyarrow version : 0.10.0
> is it not implemented yet or I am not using it correctly? If not implemented 
> yet, then any work around to cast columns?



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

Reply via email to