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

Function test_value_counts_simple

python/pyarrow/tests/test_array.py:2136–2155  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2134
2135
2136def test_value_counts_simple():
2137 cases = [
2138 (pa.array([1, 2, 3, 1, 2, 3]),
2139 pa.array([1, 2, 3]),
2140 pa.array([2, 2, 2], type=pa.int64())),
2141 (pa.array(['foo', None, 'bar', 'foo']),
2142 pa.array(['foo', None, 'bar']),
2143 pa.array([2, 1, 1], type=pa.int64())),
2144 (pa.array(['foo', None, 'bar', 'foo'], pa.large_binary()),
2145 pa.array(['foo', None, 'bar'], pa.large_binary()),
2146 pa.array([2, 1, 1], type=pa.int64())),
2147 ]
2148 for arr, expected_values, expected_counts in cases:
2149 for arr_in in (arr, pa.chunked_array([arr])):
2150 result = arr_in.value_counts()
2151 assert result.type.equals(
2152 pa.struct([pa.field("values", arr.type),
2153 pa.field("counts", pa.int64())]))
2154 assert result.field("values").equals(expected_values)
2155 assert result.field("counts").equals(expected_counts)
2156
2157
2158def test_unique_value_counts_dictionary_type():

Callers

nothing calls this directly

Calls 4

chunked_arrayMethod · 0.80
equalsMethod · 0.80
arrayMethod · 0.45
fieldMethod · 0.45

Tested by

no test coverage detected