You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@arrow.apache.org by "Antoine Pitrou (Jira)" <ji...@apache.org> on 2021/05/12 11:08:00 UTC

[jira] [Closed] (ARROW-12387) [C++][Python] cannot cast float64 array to int64

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

Antoine Pitrou closed ARROW-12387.
----------------------------------
    Fix Version/s:     (was: 5.0.0)
       Resolution: Not A Problem

Closing since this is by design and can circumvented.

> [C++][Python] cannot cast float64 array to int64
> ------------------------------------------------
>
>                 Key: ARROW-12387
>                 URL: https://issues.apache.org/jira/browse/ARROW-12387
>             Project: Apache Arrow
>          Issue Type: Bug
>          Components: C++, Python
>    Affects Versions: 3.0.0
>            Reporter: Taras Kuzyo
>            Priority: Major
>
>  
> {code:java}
> >>> arr = [0.992133801741256, 0.993103448275862]
> >>> a = pa.scalar(arr[0], pa.float64())
> >>> pc.multiply(a, 1e8).cast(pa.int64())
> <pyarrow.Int64Scalar: 99213380>
> >>> b = pa.array(arr, pa.float64())
> >>> pc.multiply(b, 1e8).cast(pa.int64())
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
>  File "pyarrow/array.pxi", line 810, in pyarrow.lib.Array.cast
>  File "/usr/local/lib/python3.6/dist-packages/pyarrow/compute.py", line 281, in cast
>  return call_function("cast", [arr], options)
>  File "pyarrow/_compute.pyx", line 465, in pyarrow._compute.call_function
>  File "pyarrow/_compute.pyx", line 294, in pyarrow._compute.Function.call
>  File "pyarrow/error.pxi", line 122, in pyarrow.lib.pyarrow_internal_check_status
>  File "pyarrow/error.pxi", line 84, in pyarrow.lib.check_status
> pyarrow.lib.ArrowInvalid: Float value 9.92134e+07 was truncated converting toint64
> {code}
>  



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