From ba76d460577c82772ffb84762e42401a4d575677 Mon Sep 17 00:00:00 2001 From: Christian Stade-Schuldt Date: Thu, 1 Jun 2017 16:10:27 +0200 Subject: [PATCH] add implementation of is_monotonic_decreasing to MultiIndex --- pandas/core/indexes/multi.py | 2 +- pandas/tests/indexes/test_multi.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/pandas/core/indexes/multi.py b/pandas/core/indexes/multi.py index 981a6a696a618..b6f1bddfb0dc8 100644 --- a/pandas/core/indexes/multi.py +++ b/pandas/core/indexes/multi.py @@ -713,7 +713,7 @@ def is_monotonic_decreasing(self): return if the index is monotonic decreasing (only equal or decreasing) values. """ - return False + return not self.is_strictly_monotonic_increasing or self.nunique() == 1 @cache_readonly def is_unique(self): diff --git a/pandas/tests/indexes/test_multi.py b/pandas/tests/indexes/test_multi.py index 388a49d25cb82..4b5d1f45d821a 100644 --- a/pandas/tests/indexes/test_multi.py +++ b/pandas/tests/indexes/test_multi.py @@ -2436,7 +2436,6 @@ def test_is_strictly_monotonic(self): assert idx.is_monotonic_increasing assert not idx.is_strictly_monotonic_increasing - @pytest.mark.xfail(reason="buggy MultiIndex.is_monotonic_decresaing.") def test_is_strictly_monotonic_decreasing(self): idx = pd.MultiIndex(levels=[['baz', 'bar'], ['next', 'mom']], labels=[[0, 0, 1, 1], [0, 0, 0, 1]])