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

Function test_categorical

python/pyarrow/tests/interchange/test_interchange_spec.py:140–152  ·  view source on GitHub ↗
(use_batch)

Source from the content-addressed store, hash-verified

138
139@pytest.mark.parametrize("use_batch", [False, True])
140def test_categorical(use_batch):
141 import pyarrow as pa
142 arr = ["Mon", "Tue", "Mon", "Wed", "Mon", "Thu", "Fri", "Sat", None]
143 table = pa.table(
144 {"weekday": pa.array(arr).dictionary_encode()}
145 )
146 if use_batch:
147 table = table.to_batches()[0]
148
149 col = table.__dataframe__().get_column_by_name("weekday")
150 categorical = col.describe_categorical
151 assert isinstance(categorical["is_ordered"], bool)
152 assert isinstance(categorical["is_dictionary"], bool)
153
154
155@pytest.mark.parametrize("use_batch", [False, True])

Callers

nothing calls this directly

Calls 4

to_batchesMethod · 0.80
get_column_by_nameMethod · 0.80
__dataframe__Method · 0.80
arrayMethod · 0.45

Tested by

no test coverage detected