Skip to content

Commit

Permalink
Add tests for usecols and index col combinations (#44951)
Browse files Browse the repository at this point in the history
  • Loading branch information
phofl authored Dec 18, 2021
1 parent 50adb83 commit 47eb219
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions pandas/tests/io/parser/usecols/test_usecols_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,28 @@ def test_usecols_implicit_index_col(all_parsers):
tm.assert_frame_equal(result, expected)


def test_usecols_index_col_middle(all_parsers):
# GH#9098
parser = all_parsers
data = """a,b,c,d
1,2,3,4
"""
result = parser.read_csv(StringIO(data), usecols=["b", "c", "d"], index_col="c")
expected = DataFrame({"b": [2], "d": [4]}, index=Index([3], name="c"))
tm.assert_frame_equal(result, expected)


def test_usecols_index_col_end(all_parsers):
# GH#9098
parser = all_parsers
data = """a,b,c,d
1,2,3,4
"""
result = parser.read_csv(StringIO(data), usecols=["b", "c", "d"], index_col="d")
expected = DataFrame({"b": [2], "c": [3]}, index=Index([4], name="d"))
tm.assert_frame_equal(result, expected)


def test_usecols_regex_sep(all_parsers):
# see gh-2733
parser = all_parsers
Expand Down

0 comments on commit 47eb219

Please sign in to comment.