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

Function test_mode_array

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

Source from the content-addressed store, hash-verified

474
475
476def test_mode_array():
477 # ARROW-9917
478 arr = pa.array([1, 1, 3, 4, 3, 5], type='int64')
479 mode = pc.mode(arr)
480 assert len(mode) == 1
481 assert mode[0].as_py() == {"mode": 1, "count": 2}
482
483 mode = pc.mode(arr, n=2)
484 assert len(mode) == 2
485 assert mode[0].as_py() == {"mode": 1, "count": 2}
486 assert mode[1].as_py() == {"mode": 3, "count": 2}
487
488 arr = pa.array([], type='int64')
489 assert len(pc.mode(arr)) == 0
490
491 arr = pa.array([1, 1, 3, 4, 3, None], type='int64')
492 mode = pc.mode(arr, skip_nulls=False)
493 assert len(mode) == 0
494 mode = pc.mode(arr, min_count=6)
495 assert len(mode) == 0
496 mode = pc.mode(arr, skip_nulls=False, min_count=5)
497 assert len(mode) == 0
498
499 arr = pa.array([True, False])
500 mode = pc.mode(arr, n=2)
501 assert len(mode) == 2
502 assert mode[0].as_py() == {"mode": False, "count": 1}
503 assert mode[1].as_py() == {"mode": True, "count": 1}
504
505
506def 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