diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 3b0cc5619a1cd..3d3d56c1e0331 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -2559,15 +2559,17 @@ def insert(self, loc, column, value, allow_duplicates=False): """ Insert column into DataFrame at specified location. - If `allow_duplicates` is False, raises Exception if column - is already contained in the DataFrame. + Raises a ValueError if `column` is already contained in the DataFrame, + unless `allow_duplicates` is set to True. Parameters ---------- loc : int - Must have 0 <= loc <= len(columns) - column : object - value : scalar, Series, or array-like + Insertion index. Must verify 0 <= loc <= len(columns) + column : string, number, or hashable object + label of the inserted column + value : int, Series, or array-like + allow_duplicates : bool, optional """ self._ensure_valid_index(value) value = self._sanitize_column(column, value, broadcast=False)