Skip to content

Commit 148f87d

Browse files
committed
Initial testcase for read_csv
1 parent 1d153bb commit 148f87d

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

pandas/tests/io/parser/usecols/test_usecols_basic.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,3 +545,27 @@ def test_usecols_dtype(all_parsers):
545545
{"col1": array(["a", "b"]), "col2": np.array([1, 2], dtype="uint8")}
546546
)
547547
tm.assert_frame_equal(result, expected)
548+
549+
550+
@pytest.mark.parametrize("usecols", [(2, 0), ("c", "a")])
551+
def test_usecols_order(all_parsers, usecols, request):
552+
# TODO add future flag
553+
parser = all_parsers
554+
data = """\
555+
a,b,c,d
556+
1,2,3,0
557+
4,5,6,
558+
7,8,9,0
559+
10,11,12,13"""
560+
# print(usecols)
561+
# print(data)
562+
563+
if parser.engine == "pyarrow" and isinstance(usecols[0], int):
564+
with pytest.raises(ValueError, match=_msg_pyarrow_requires_names):
565+
parser.read_csv(StringIO(data), usecols=usecols)
566+
return
567+
568+
result = parser.read_csv(StringIO(data), usecols=usecols)
569+
570+
expected = DataFrame([[3, 1], [6, 4], [9, 7], [12, 10]], columns=["c", "a"])
571+
tm.assert_frame_equal(result, expected)

0 commit comments

Comments
 (0)