MCPcopy Create free account
hub / github.com/apache/arrow / test_mode_array

Function test_mode_array

python/pyarrow/tests/test_compute.py:471–498  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

469
470
471def test_mode_array():
472 # ARROW-9917
473 arr = pa.array([1, 1, 3, 4, 3, 5], type='int64')
474 mode = pc.mode(arr)
475 assert len(mode) == 1
476 assert mode[0].as_py() == {"mode": 1, "count": 2}
477
478 mode = pc.mode(arr, n=2)
479 assert len(mode) == 2
480 assert mode[0].as_py() == {"mode": 1, "count": 2}
481 assert mode[1].as_py() == {"mode": 3, "count": 2}
482
483 arr = pa.array([], type='int64')
484 assert len(pc.mode(arr)) == 0
485
486 arr = pa.array([1, 1, 3, 4, 3, None], type='int64')
487 mode = pc.mode(arr, skip_nulls=False)
488 assert len(mode) == 0
489 mode = pc.mode(arr, min_count=6)
490 assert len(mode) == 0
491 mode = pc.mode(arr, skip_nulls=False, min_count=5)
492 assert len(mode) == 0
493
494 arr = pa.array([True, False])
495 mode = pc.mode(arr, n=2)
496 assert len(mode) == 2
497 assert mode[0].as_py() == {"mode": False, "count": 1}
498 assert mode[1].as_py() == {"mode": True, "count": 1}
499
500
501def test_mode_chunked_array():

Callers

nothing calls this directly

Calls 4

lenFunction · 0.85
as_pyMethod · 0.80
arrayMethod · 0.45
modeMethod · 0.45

Tested by

no test coverage detected