pyarrow.compute.fill_null#

pyarrow.compute.fill_null(values,fill_value)[source]#

Replace each null element in values with a correspondingelement from fill_value.

If fill_value is scalar-like, then every null element in valueswill be replaced with fill_value. If fill_value is array-like,then the i-th element in values will be replaced with the i-thelement in fill_value.

The fill_value’s type must be the same as that of values, or itmust be able to be implicitly casted to the array’s type.

This is an alias forcoalesce().

Parameters:
valuesArray,ChunkedArray, or Scalar-like object

Each null element is replaced with the corresponding valuefrom fill_value.

fill_valueArray,ChunkedArray, or Scalar-like object

If not same type as values, will attempt to cast.

Returns:
resultdepends on inputs

Values with all null elements replaced

Examples

>>>importpyarrowaspa>>>arr=pa.array([1,2,None,3],type=pa.int8())>>>fill_value=pa.scalar(5,type=pa.int8())>>>arr.fill_null(fill_value)<pyarrow.lib.Int8Array object at ...>[  1,  2,  5,  3]>>>arr=pa.array([1,2,None,4,None])>>>arr.fill_null(pa.array([10,20,30,40,50]))<pyarrow.lib.Int64Array object at ...>[  1,  2,  30,  4,  50]