Finwood opened a new issue, #46021:
URL: https://github.com/apache/arrow/issues/46021

   ### Describe the enhancement requested
   
   While PyArrow supports the float16 data type, it cannot be parsed directly 
from Python:
   
   ```python
   import pyarrow as pa
   
   pa.scalar(3.1415, pa.float64())
   # <pyarrow.DoubleScalar: 3.1415>
   
   pa.scalar(3.1415, pa.float32())
   # <pyarrow.FloatScalar: 3.1414999961853027>
   
   pa.scalar(3.1415, pa.float16())
   # Traceback (most recent call last):
   #   File "<stdin>", line 1, in <module>
   #   File "pyarrow/scalar.pxi", line 1293, in pyarrow.lib.scalar
   #   File "pyarrow/error.pxi", line 155, in 
pyarrow.lib.pyarrow_internal_check_status
   #   File "pyarrow/error.pxi", line 92, in pyarrow.lib.check_status
   # pyarrow.lib.ArrowTypeError: Expected np.float16 instance
   ```
   
   Taking the detour over numpy works, but is impractical in many cases:
   
   ```python
   import pyarrow as pa
   import numpy as np
   
   pa.scalar(np.float16(3.1415), pa.float16())
   # <pyarrow.HalfFloatScalar: 3.14>
   ```
   
   What would it take to add direct parsing support, to e.g. load data from 
JSON without having to handle float16 types differently?
   
   ---
   
   _Tested on pyarrow 19.0.1, Python 3.12.9_
   
   
   ### Component(s)
   
   Python


-- 
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: issues-unsubscr...@arrow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to