pyarrow.float16#

pyarrow.float16()#

Create half-precision floating point type.

Examples

Create an instance of float16 type:

>>>importpyarrowaspa>>>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 arrayto a python list, the types of its elements will benp.float16

>>>[type(val)forvalina.to_pylist()][<class 'float'>, <class 'float'>]