pyarrow.compute.mode¶
- 
pyarrow.compute.mode(array, n=1)[source]¶
- Return top-n most common values and number of times they occur in a passed numerical (chunked) array, in descending order of occurance. If there are more than one values with same count, smaller one is returned first. - Parameters
- array (pyarrow.Array or pyarrow.ChunkedArray) – 
- Returns
- An array of <input type “Mode”, int64_t “Count”> structs 
 - Examples - >>> import pyarrow as pa >>> import pyarrow.compute as pc >>> arr = pa.array([1, 1, 2, 2, 3, 2, 2, 2]) >>> modes = pc.mode(arr, 2) >>> modes[0] <pyarrow.StructScalar: {'mode': 2, 'count': 5}> >>> modes[1] <pyarrow.StructScalar: {'mode': 1, 'count': 2}> 
