pyarrow.compute.max#

pyarrow.compute.max(array,/,*,skip_nulls=True,min_count=1,options=None,memory_pool=None)#

Compute the minimum or maximum values of a numeric array.

Null values are ignored by default.This can be changed through ScalarAggregateOptions.

Parameters:
arrayArray-like

Argument to compute function.

skip_nullsbool, defaultTrue

Whether to skip (ignore) nulls in the input.If False, any null in the input forces the output to null.

min_countint, default 1

Minimum number of non-null values in the input. If the numberof non-null values is belowmin_count, the output is null.

optionspyarrow.compute.ScalarAggregateOptions, optional

Alternative way of passing options.

memory_poolpyarrow.MemoryPool, optional

If not passed, will allocate memory from the default memory pool.

Examples

>>>importpyarrowaspa>>>importpyarrow.computeaspc>>>arr1=pa.array([1,1,2,2,3,2,2,2])>>>pc.max(arr1)<pyarrow.Int64Scalar: 3>

Usingskip_nulls to handle null values.

>>>arr2=pa.array([1.0,None,2.0,3.0])>>>pc.max(arr2)<pyarrow.DoubleScalar: 3.0>>>>pc.max(arr2,skip_nulls=False)<pyarrow.DoubleScalar: None>

UsingScalarAggregateOptions to control minimum number of non-null values.

>>>arr3=pa.array([1.0,None,float("nan"),3.0])>>>pc.max(arr3)<pyarrow.DoubleScalar: 3.0>>>>pc.max(arr3,options=pc.ScalarAggregateOptions(min_count=3))<pyarrow.DoubleScalar: 3.0>>>>pc.max(arr3,options=pc.ScalarAggregateOptions(min_count=4))<pyarrow.DoubleScalar: None>

This function also works with string values.

>>>arr4=pa.array(["z",None,"y","x"])>>>pc.max(arr4)<pyarrow.StringScalar: 'z'>