Skip to content

Commit b0ddd3e

Browse files
Updated the docs and the error message to be more idiomatic.
1 parent 35207c6 commit b0ddd3e

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

doc/source/whatsnew/v1.1.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1119,7 +1119,7 @@ Other
11191119
- :class:`IntegerArray` now implements the ``sum`` operation (:issue:`33172`)
11201120
- Bug in :class:`Tick` comparisons raising ``TypeError`` when comparing against timedelta-like objects (:issue:`34088`)
11211121
- Bug in :class:`Tick` multiplication raising ``TypeError`` when multiplying by a float (:issue:`34486`)
1122-
- Passing a `set` as `names` argument to :func:`pandas.read_csv`, :func:`pandas.read_table`, or :func:`pandas.read_fwf` will raise ``ValueError: Names should have consistent ordering. Consider a list instead.`` (:issue:`34946`)
1122+
- Passing a `set` as `names` argument to :func:`pandas.read_csv`, :func:`pandas.read_table`, or :func:`pandas.read_fwf` will raise ``ValueError: Names should be an ordered collection.`` (:issue:`34946`)
11231123

11241124
.. ---------------------------------------------------------------------------
11251125

pandas/io/parsers.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -408,15 +408,13 @@ def _validate_names(names):
408408
Raises
409409
------
410410
ValueError
411-
If names are not unique or have inconsistent ordering (e.g. set).
411+
If names are not unique or are not ordered (e.g. set).
412412
"""
413413
if names is not None:
414414
if len(names) != len(set(names)):
415415
raise ValueError("Duplicate names are not allowed.")
416416
if not is_list_like(names, allow_sets=False):
417-
raise ValueError(
418-
"Names should have consistent ordering. Consider a list instead."
419-
)
417+
raise ValueError("Names should be an ordered collection.")
420418

421419

422420
def _read(filepath_or_buffer: FilePathOrBuffer, kwds):

pandas/tests/io/parser/test_common.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2145,7 +2145,7 @@ def test_read_csv_names_types(all_parsers):
21452145
7,8,9
21462146
10,11,12\n"""
21472147
parser = all_parsers
2148-
msg = "Names should have consistent ordering. Consider a list instead."
2148+
msg = "Names should be an ordered collection."
21492149
names = "QAZ"
21502150
with pytest.raises(ValueError, match=msg):
21512151
parser.read_csv(StringIO(data), names=set(names))

0 commit comments

Comments
 (0)