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

Antoine Pitrou commented on ARROW-2856:
---------------------------------------

Yes, we raise on NaN as well:
{code:python}
>>> pa.array([float('nan')], type=pa.int8())
Traceback (most recent call last):
  File "<ipython-input-3-357aa3c7f8d3>", line 1, in <module>
    pa.array([float('nan')], type=pa.int8())
  File "pyarrow/array.pxi", line 186, in pyarrow.lib.array
    return _sequence_to_array(obj, size, type, pool, from_pandas)
  File "pyarrow/array.pxi", line 40, in pyarrow.lib._sequence_to_array
    check_status(
  File "pyarrow/error.pxi", line 81, in pyarrow.lib.check_status
    raise ArrowInvalid(message)
ArrowInvalid: ../src/arrow/python/builtin_convert.cc:920 code: 
AppendPySequence(seq, size, real_type, builder.get(), from_pandas)
../src/arrow/python/iterators.h:60 code: func(value)
../src/arrow/python/builtin_convert.cc:454 code: internal::CIntFromPython(obj, 
&value)
../src/arrow/python/helpers.cc:259 code: CheckPyError()
cannot convert float NaN to integer
{code}


> [Python/C++] Array constructor should not truncate floats when casting to int
> -----------------------------------------------------------------------------
>
>                 Key: ARROW-2856
>                 URL: https://issues.apache.org/jira/browse/ARROW-2856
>             Project: Apache Arrow
>          Issue Type: Bug
>          Components: Python
>    Affects Versions: 0.9.0
>            Reporter: Florian Jetter
>            Priority: Minor
>             Fix For: 0.10.0
>
>
> I would expect the following code to raise instead of truncating the float
> {code}
> In [4]: pa.array([1.9], type=pa.int8())
> Out[4]:
> <pyarrow.lib.Int8Array object at 0x113455e58>
> [
>   1
> ]
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to