MCPcopy
hub / github.com/pandas-dev/pandas / test_chunked_categorical_partial

Function test_chunked_categorical_partial

pandas/tests/io/test_stata.py:2320–2337  ·  view source on GitHub ↗
(datapath)

Source from the content-addressed store, hash-verified

2318
2319
2320def test_chunked_categorical_partial(datapath):
2321 dta_file = datapath("io", "data", "stata", "stata-dta-partially-labeled.dta")
2322 values = ["a", "b", "a", "b", 3.0]
2323 msg = "series with value labels are not fully labeled"
2324 with StataReader(dta_file, chunksize=2) as reader:
2325 with tm.assert_produces_warning(CategoricalConversionWarning, match=msg):
2326 for i, block in enumerate(reader):
2327 assert list(block.cats) == values[2 * i : 2 * (i + 1)]
2328 if i < 2:
2329 idx = pd.Index(["a", "b"])
2330 else:
2331 idx = pd.Index([3.0], dtype="float64")
2332 tm.assert_index_equal(block.cats.cat.categories, idx)
2333 with tm.assert_produces_warning(CategoricalConversionWarning, match=msg):
2334 with StataReader(dta_file, chunksize=5) as reader:
2335 large_chunk = reader.__next__()
2336 direct = read_stata(dta_file)
2337 tm.assert_frame_equal(direct, large_chunk)
2338
2339
2340@pytest.mark.parametrize("chunksize", (-1, 0, "apple"))

Callers

nothing calls this directly

Calls 4

StataReaderClass · 0.90
read_stataFunction · 0.90
datapathFunction · 0.85
__next__Method · 0.45

Tested by

no test coverage detected