Skip to content

[Python] Unable to cast HalffloatArray to Float or Double #18803

@asfimport

Description

@asfimport

I'm not able to cast the float16 type to float32/float64, here is a repro:

>>> import pyarrow as pa
>>> import numpy as np
>>> pa.array(np.array([1, 2.0], dtype='float32')).cast(pa.float64())
<pyarrow.lib.DoubleArray object at 0x7fa67cc56760>
[
  1,
  2
]
>>> pa.array(np.array([1, 2.0], dtype='float16')).cast(pa.float64())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pyarrow/array.pxi", line 816, in pyarrow.lib.Array.cast
  File "/home/pgali/anaconda3/envs/cudf_dev/lib/python3.8/site-packages/pyarrow/compute.py", line 297, in cast
    return call_function("cast", [arr], options)
  File "pyarrow/_compute.pyx", line 527, in pyarrow._compute.call_function
  File "pyarrow/_compute.pyx", line 337, in pyarrow._compute.Function.call
  File "pyarrow/error.pxi", line 143, in pyarrow.lib.pyarrow_internal_check_status
  File "pyarrow/error.pxi", line 120, in pyarrow.lib.check_status
pyarrow.lib.ArrowNotImplementedError: Unsupported cast from halffloat to double using function cast_double
>>> 

Reporter: Prem Sagar Gali / @galipremsagar

Related issues:

Note: This issue was originally created as ARROW-13762. Please see the migration documentation for further details.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions