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:1499–1514  ·  view source on GitHub ↗
(tmpdir)

Source from the content-addressed store, hash-verified

1497
1498@pytest.mark.pandas
1499def test_native_file_pandas_text_reader(tmpdir):
1500 # ARROW-16272: Pandas' read_csv() should not exhaust an Arrow
1501 # input stream when a small nrows is passed.
1502 import pandas as pd
1503 import pandas.testing as tm
1504 data = b'a,b\n' * 10_000_000
1505 path = str(tmpdir / 'largefile.txt')
1506 with open(path, 'wb') as f:
1507 f.write(data)
1508
1509 with pa.OSFile(path, mode='rb') as f:
1510 df = pd.read_csv(f, nrows=10)
1511 expected = pd.DataFrame({'a': ['a'] * 10, 'b': ['b'] * 10})
1512 tm.assert_frame_equal(df, expected)
1513 # Some readahead occurred, but not up to the end of file
1514 assert f.tell() <= 256 * 1024
1515
1516
1517def 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