Skip to content

Add missing space in read_csv usecols out-of-bounds case #55651

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pandas/_libs/parsers.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ cdef class TextReader:
missing_usecols = [col for col in self.usecols if col >= num_cols]
if missing_usecols:
raise ParserError(
"Defining usecols without of bounds indices is not allowed. "
"Defining usecols with out-of-bounds indices is not allowed. "
f"{missing_usecols} are out of bounds.",
)

Expand Down
4 changes: 2 additions & 2 deletions pandas/io/parsers/python_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,8 +615,8 @@ def _handle_usecols(
]
if missing_usecols:
raise ParserError(
"Defining usecols without of bounds indices is not allowed. "
f"{missing_usecols} are out of bounds.",
"Defining usecols with out-of-bounds indices is not allowed. "
f"{missing_usecols} are out-of-bounds.",
)
col_indices = self.usecols

Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/io/parser/usecols/test_usecols_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ def test_usecols_indices_out_of_bounds(all_parsers, names):
a,b
1,2
"""
with pytest.raises(ParserError, match="Defining usecols without of bounds"):
with pytest.raises(ParserError, match="Defining usecols with out-of-bounds"):
parser.read_csv(StringIO(data), usecols=[0, 2], names=names, header=0)


Expand Down