From d714c5d07af65afbffb7320131cdac59b93dd3e0 Mon Sep 17 00:00:00 2001 From: Max van Deursen Date: Thu, 28 Feb 2019 12:36:10 +0100 Subject: [PATCH 1/3] Correct Raises in DataFrame.drop documentation In this commit, the description in the documentation for the DataFrame.drop function is corrected. Prior to this commit, the provided condition for throwing a KeyError was not aligned with the behaviour of the code. After this commit, this condition is. --- pandas/core/frame.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 608e5c53ec094..36936c82da57f 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -3817,7 +3817,7 @@ def drop(self, labels=None, axis=0, index=None, columns=None, Raises ------ KeyError - If none of the labels are found in the selected axis + If one of the labels is not found in the selected axis. See Also -------- From 7a46752504899401f524859e603e2202945889cf Mon Sep 17 00:00:00 2001 From: Max van Deursen Date: Thu, 28 Feb 2019 12:37:49 +0100 Subject: [PATCH 2/3] Fix linting errors in DataFrame.drop documentation In this commit, the linting errors in the DataFrame.drop documentation are removed, by fixing the respective errors. --- pandas/core/frame.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 36936c82da57f..14166a64f033a 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -3797,7 +3797,12 @@ def drop(self, labels=None, axis=0, index=None, columns=None, axis : {0 or 'index', 1 or 'columns'}, default 0 Whether to drop labels from the index (0 or 'index') or columns (1 or 'columns'). - index, columns : single label or list-like + index : single label or list-like + Alternative to specifying axis (``labels, axis=0`` + is equivalent to ``index=labels``). + + .. versionadded:: 0.21.0 + columns : single label or list-like Alternative to specifying axis (``labels, axis=1`` is equivalent to ``columns=labels``). @@ -3813,6 +3818,7 @@ def drop(self, labels=None, axis=0, index=None, columns=None, Returns ------- DataFrame + DataFrame without the removed index or column labels. Raises ------ @@ -3830,7 +3836,7 @@ def drop(self, labels=None, axis=0, index=None, columns=None, Examples -------- - >>> df = pd.DataFrame(np.arange(12).reshape(3,4), + >>> df = pd.DataFrame(np.arange(12).reshape(3, 4), ... columns=['A', 'B', 'C', 'D']) >>> df A B C D @@ -3867,7 +3873,7 @@ def drop(self, labels=None, axis=0, index=None, columns=None, >>> df = pd.DataFrame(index=midx, columns=['big', 'small'], ... data=[[45, 30], [200, 100], [1.5, 1], [30, 20], ... [250, 150], [1.5, 0.8], [320, 250], - ... [1, 0.8], [0.3,0.2]]) + ... [1, 0.8], [0.3, 0.2]]) >>> df big small lama speed 45.0 30.0 From b0d89576797523bf644bfdfceb9f4a7df9899600 Mon Sep 17 00:00:00 2001 From: Max van Deursen Date: Thu, 28 Feb 2019 12:58:47 +0100 Subject: [PATCH 3/3] Fix changes by left feedback In this commit, the feedback is implemented into the code changes. --- pandas/core/frame.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 14166a64f033a..a40733b7076b0 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -3823,7 +3823,7 @@ def drop(self, labels=None, axis=0, index=None, columns=None, Raises ------ KeyError - If one of the labels is not found in the selected axis. + If any of the labels is not found in the selected axis. See Also --------