From dcb50b7e8bdcdaebebc5ac577d9a8ba6ceef1d74 Mon Sep 17 00:00:00 2001 From: phofl Date: Sat, 12 Sep 2020 03:26:25 +0200 Subject: [PATCH 1/4] Improve doc for df.drop() --- pandas/core/frame.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 59cf4c0e2f81d..261202330c375 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -4093,7 +4093,9 @@ def drop( Remove rows or columns by specifying label names and corresponding axis, or by specifying directly index or column names. When using a multi-index, labels on different levels can be removed by specifying - the level. + the level. In case of a multi-index either a level must be defined or + the labels must be a list of tuples the same length as the levels of + the multi-index. Parameters ---------- From 75a45c17d3498d6591323b4d107c3fd440b1f531 Mon Sep 17 00:00:00 2001 From: phofl Date: Sat, 12 Sep 2020 03:32:56 +0200 Subject: [PATCH 2/4] Improve docstring for isin --- pandas/core/indexes/base.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 8014b16d07b01..5698831ad8e81 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -4902,7 +4902,9 @@ def isin(self, values, level=None): Compute boolean array of whether each index value is found in the passed set of values. The length of the returned boolean array matches - the length of the index. + the length of the index. If the index is a multi-index and no level is + given, the values must be given as list containing tuples with the same + length as the mulit-index. Parameters ---------- From a935c9c02fbdf56737bd4bbcce07fbdca0aef7c0 Mon Sep 17 00:00:00 2001 From: phofl Date: Sun, 13 Sep 2020 10:11:44 +0200 Subject: [PATCH 3/4] Add recommendations --- pandas/core/frame.py | 8 ++++---- pandas/core/indexes/base.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 261202330c375..3aa6fe70387e7 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -4092,10 +4092,10 @@ def drop( Remove rows or columns by specifying label names and corresponding axis, or by specifying directly index or column names. When using a - multi-index, labels on different levels can be removed by specifying - the level. In case of a multi-index either a level must be defined or - the labels must be a list of tuples the same length as the levels of - the multi-index. + MultiIndex, labels on different levels can be removed by specifying + the level. In case of a MultiIndex either a level must be defined or + the labels must be a list of tuples of the same length as the number + of levels in the MultiIndex. Parameters ---------- diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 5698831ad8e81..0f1be0468aef1 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -4903,8 +4903,8 @@ def isin(self, values, level=None): Compute boolean array of whether each index value is found in the passed set of values. The length of the returned boolean array matches the length of the index. If the index is a multi-index and no level is - given, the values must be given as list containing tuples with the same - length as the mulit-index. + given, the values must be given as list containing tuples of the same + length as the number of levels in the MultiIndex. Parameters ---------- From b9972e5ecf95103e43def66ba04bd1b093c60531 Mon Sep 17 00:00:00 2001 From: phofl Date: Wed, 23 Sep 2020 23:02:47 +0200 Subject: [PATCH 4/4] Add docs from other pr --- pandas/core/frame.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 3aa6fe70387e7..4548118a61f92 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -4093,9 +4093,10 @@ def drop( Remove rows or columns by specifying label names and corresponding axis, or by specifying directly index or column names. When using a MultiIndex, labels on different levels can be removed by specifying - the level. In case of a MultiIndex either a level must be defined or - the labels must be a list of tuples of the same length as the number - of levels in the MultiIndex. + the level. The now-unused levels remain in the + MultiIndex._levels attribute. In case of a MultiIndex either a level + must be defined or the labels must be a list of tuples of the same + length as the number of levels in the MultiIndex. Parameters ----------