diff --git a/doc/source/whatsnew/v0.25.0.rst b/doc/source/whatsnew/v0.25.0.rst index 461c883f542ab..0e8cd95084a8d 100644 --- a/doc/source/whatsnew/v0.25.0.rst +++ b/doc/source/whatsnew/v0.25.0.rst @@ -434,6 +434,7 @@ Other API Changes - The ``arg`` argument in :meth:`pandas.core.groupby.DataFrameGroupBy.agg` has been renamed to ``func`` (:issue:`26089`) - The ``arg`` argument in :meth:`pandas.core.window._Window.aggregate` has been renamed to ``func`` (:issue:`26372`) - Most Pandas classes had a ``__bytes__`` method, which was used for getting a python2-style bytestring representation of the object. This method has been removed as a part of dropping Python2 (:issue:`26447`) +- The `.str`-accessor has been disabled for 1-level :class:`MultiIndex`, use :meth:`MultiIndex.to_flat_index` if necessary (:issue:`23679`) - Removed support of gtk package for clipboards (:issue:`26563`) .. _whatsnew_0250.deprecations: diff --git a/pandas/tests/test_strings.py b/pandas/tests/test_strings.py index 1ba0ef3918fb7..a1d522930e9aa 100644 --- a/pandas/tests/test_strings.py +++ b/pandas/tests/test_strings.py @@ -169,6 +169,14 @@ def test_api(self): assert Series.str is strings.StringMethods assert isinstance(Series(['']).str, strings.StringMethods) + def test_api_mi_raises(self): + # GH 23679 + mi = MultiIndex.from_arrays([['a', 'b', 'c']]) + with pytest.raises(AttributeError, match='Can only use .str accessor ' + 'with Index, not MultiIndex'): + mi.str + assert not hasattr(mi, 'str') + @pytest.mark.parametrize('dtype', [object, 'category']) @pytest.mark.parametrize('box', [Series, Index]) def test_api_per_dtype(self, box, dtype, any_skipna_inferred_dtype):