Skip to content

DOC: fix _validate_names docstring #29729

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 3 commits into from
Nov 20, 2019
Merged
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
13 changes: 5 additions & 8 deletions pandas/io/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,25 +395,22 @@ def _validate_integer(name, val, min_val=0):

def _validate_names(names):
"""
Check if the `names` parameter contains duplicates.

If duplicates are found, we issue a warning before returning.
Raise ValueError if the `names` parameter contains duplicates.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a Raises section

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated+green


Parameters
----------
names : array-like or None
An array containing a list of the names used for the output DataFrame.

Returns
-------
names : array-like or None
The original `names` parameter.
Raises
------
ValueError
If names are not unique.
"""

if names is not None:
if len(names) != len(set(names)):
raise ValueError("Duplicate names are not allowed.")
return names


def _read(filepath_or_buffer: FilePathOrBuffer, kwds):
Expand Down