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

Function test_stream_categorical_roundtrip

python/pyarrow/tests/test_ipc.py:268–281  ·  view source on GitHub ↗
(stream_fixture)

Source from the content-addressed store, hash-verified

266
267@pytest.mark.pandas
268def test_stream_categorical_roundtrip(stream_fixture):
269 df = pd.DataFrame({
270 'one': np.random.randn(5),
271 'two': pd.Categorical(['foo', np.nan, 'bar', 'foo', 'foo'],
272 categories=['foo', 'bar'],
273 ordered=True)
274 })
275 batch = pa.RecordBatch.from_pandas(df)
276 with stream_fixture._get_writer(stream_fixture.sink, batch.schema) as wr:
277 wr.write_batch(batch)
278
279 table = (pa.ipc.open_stream(pa.BufferReader(stream_fixture.get_source()))
280 .read_all())
281 assert_frame_equal(table.to_pandas(), df)
282
283
284def test_open_stream_from_buffer(stream_fixture):

Callers

nothing calls this directly

Calls 4

write_batchMethod · 0.80
BufferReaderMethod · 0.80
get_sourceMethod · 0.80
_get_writerMethod · 0.45

Tested by

no test coverage detected