| [ Web Proxy ] |
| Viewing: https://arrow.apache.org/docs/python/generated/pyarrow.float16.html | [Back] [Original] |
Section Navigation
Create half-precision floating point type.
Examples
Create an instance of float16 type:
>>> import pyarrow as pa
>>> pa.float16()
DataType(halffloat)
>>> print(pa.float16())
halffloat
Create an array with float16 type:
>>> arr = np.array([1.5, np.nan], dtype=np.float16)
>>> a = pa.array(arr, type=pa.float16())
>>> a
<pyarrow.lib.HalfFloatArray object at ...>
[
1.5,
nan
]
Note that unlike other float types, if you convert this array
to a python list, the types of its elements will be np.float16
>>> [type(val) for val in a.to_pylist()]
[<class 'float'>, <class 'float'>]
Copyright 2016-2026 Apache Software Foundation.
Apache Arrow, Arrow, Apache, the Apache logo, and the Apache Arrow project logo are either registered trademarks or trademarks of The Apache Software Foundation in the United States and other countries.
Created using Sphinx 9.1.0.
Built with the PyData Sphinx Theme 0.20.0.
| Web Proxy Viewer | New URL | Original Page |