From b2fe908016d3fdaae27f88b9dcfc34f96a4a9c6a Mon Sep 17 00:00:00 2001 From: Pierre Haessig Date: Fri, 12 May 2017 14:59:18 +0200 Subject: [PATCH 1/2] minor enhancement of DataFrame.insert docstring --- pandas/core/frame.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 3b0cc5619a1cd..d64a7fb2d587b 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -2565,9 +2565,11 @@ def insert(self, loc, column, value, allow_duplicates=False): Parameters ---------- loc : int - Must have 0 <= loc <= len(columns) - column : object + Insertion index. Must verify 0 <= loc <= len(columns) + column : string, number, or hashable object + label of the column value : scalar, Series, or array-like + allow_duplicates : bool """ self._ensure_valid_index(value) value = self._sanitize_column(column, value, broadcast=False) From 3090f1fca3fc49a7683c4e58e8064ab8b058a4d0 Mon Sep 17 00:00:00 2001 From: Pierre Haessig Date: Fri, 12 May 2017 15:31:32 +0200 Subject: [PATCH 2/2] further enhancement of DataFrame.insert docstring --- pandas/core/frame.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index d64a7fb2d587b..3d3d56c1e0331 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -2559,17 +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 Insertion index. Must verify 0 <= loc <= len(columns) column : string, number, or hashable object - label of the column - value : scalar, Series, or array-like - allow_duplicates : bool + 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)