From 9d95a97428a9450be8e78b7b31f6475ac62861c8 Mon Sep 17 00:00:00 2001 From: Jason Zutty Date: Fri, 29 Aug 2014 15:23:01 -0400 Subject: [PATCH 1/4] Made subtraction behavior consistent with addition --- pandas/core/index.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pandas/core/index.py b/pandas/core/index.py index 065dcd90b8d76..463b17ccb4631 100644 --- a/pandas/core/index.py +++ b/pandas/core/index.py @@ -1141,7 +1141,10 @@ def __add__(self, other): __ge__ = _indexOp('__ge__') def __sub__(self, other): - return self.diff(other) + if isinstance(other, Index): + return self.diff(other) + else: + return Index(np.array(self) - other) def __and__(self, other): return self.intersection(other) From 4f2e4b5a4b68a88ac9bfbc7e406d1b5b173bbe5d Mon Sep 17 00:00:00 2001 From: Jason Zutty Date: Fri, 29 Aug 2014 15:23:01 -0400 Subject: [PATCH 2/4] GH8142 Made subtraction behavior consistent with addition --- pandas/core/index.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pandas/core/index.py b/pandas/core/index.py index 065dcd90b8d76..463b17ccb4631 100644 --- a/pandas/core/index.py +++ b/pandas/core/index.py @@ -1141,7 +1141,10 @@ def __add__(self, other): __ge__ = _indexOp('__ge__') def __sub__(self, other): - return self.diff(other) + if isinstance(other, Index): + return self.diff(other) + else: + return Index(np.array(self) - other) def __and__(self, other): return self.intersection(other) From 46aeac385ad474d032b4298029406de4c431922a Mon Sep 17 00:00:00 2001 From: Jason Zutty Date: Fri, 29 Aug 2014 15:31:42 -0400 Subject: [PATCH 3/4] Revert "Made subtraction behavior consistent with addition" This reverts commit 9d95a97428a9450be8e78b7b31f6475ac62861c8. --- pandas/core/index.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pandas/core/index.py b/pandas/core/index.py index 463b17ccb4631..065dcd90b8d76 100644 --- a/pandas/core/index.py +++ b/pandas/core/index.py @@ -1141,10 +1141,7 @@ def __add__(self, other): __ge__ = _indexOp('__ge__') def __sub__(self, other): - if isinstance(other, Index): - return self.diff(other) - else: - return Index(np.array(self) - other) + return self.diff(other) def __and__(self, other): return self.intersection(other) From 2a50f21b16ee4068e6cdbbfe1023121e77f41439 Mon Sep 17 00:00:00 2001 From: Jason Zutty Date: Fri, 29 Aug 2014 15:33:09 -0400 Subject: [PATCH 4/4] GH8142 Made subtraction behavior consistent with addition --- pandas/core/index.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pandas/core/index.py b/pandas/core/index.py index 065dcd90b8d76..463b17ccb4631 100644 --- a/pandas/core/index.py +++ b/pandas/core/index.py @@ -1141,7 +1141,10 @@ def __add__(self, other): __ge__ = _indexOp('__ge__') def __sub__(self, other): - return self.diff(other) + if isinstance(other, Index): + return self.diff(other) + else: + return Index(np.array(self) - other) def __and__(self, other): return self.intersection(other)