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

Function test_native_file_pandas_text_reader

python/pyarrow/tests/test_io.py:1474–1489  ·  view source on GitHub ↗
(tmpdir)

Source from the content-addressed store, hash-verified

1472
1473@pytest.mark.pandas
1474def test_native_file_pandas_text_reader(tmpdir):
1475 # ARROW-16272: Pandas' read_csv() should not exhaust an Arrow
1476 # input stream when a small nrows is passed.
1477 import pandas as pd
1478 import pandas.testing as tm
1479 data = b'a,b\n' * 10_000_000
1480 path = str(tmpdir / 'largefile.txt')
1481 with open(path, 'wb') as f:
1482 f.write(data)
1483
1484 with pa.OSFile(path, mode='rb') as f:
1485 df = pd.read_csv(f, nrows=10)
1486 expected = pd.DataFrame({'a': ['a'] * 10, 'b': ['b'] * 10})
1487 tm.assert_frame_equal(df, expected)
1488 # Some readahead occurred, but not up to the end of file
1489 assert f.tell() <= 256 * 1024
1490
1491
1492def test_native_file_open_error():

Callers

nothing calls this directly

Calls 2

writeMethod · 0.45
read_csvMethod · 0.45

Tested by

no test coverage detected