pyarrow.float16 — Apache Arrow v20.0.0 (original) (raw)

pyarrow.float16()#

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 ...> [ 15872, 32256 ]

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 'numpy.float16'>, <class 'numpy.float16'>]