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

Source from the content-addressed store, hash-verified

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