diff --git a/doc/source/whatsnew/v0.24.0.txt b/doc/source/whatsnew/v0.24.0.txt index 8cb384f50d371..efd4028f2eada 100644 --- a/doc/source/whatsnew/v0.24.0.txt +++ b/doc/source/whatsnew/v0.24.0.txt @@ -513,7 +513,7 @@ Missing MultiIndex ^^^^^^^^^^ -- +- Removed compatibility for MultiIndex pickles prior to version 0.8.0; compatibility with MultiIndex pickles from version 0.13 forward is maintained (:issue:`21654`) - - diff --git a/pandas/core/indexes/multi.py b/pandas/core/indexes/multi.py index 7d24a901382bb..4912014b43773 100644 --- a/pandas/core/indexes/multi.py +++ b/pandas/core/indexes/multi.py @@ -824,15 +824,6 @@ def values(self): self._tuples = lib.fast_zip(values) return self._tuples - # fml - @property - def _is_v1(self): - return False - - @property - def _is_v2(self): - return False - @property def _has_complex_internals(self): # to disable groupby tricks @@ -2843,22 +2834,6 @@ def delete(self, loc): return MultiIndex(levels=self.levels, labels=new_labels, names=self.names, verify_integrity=False) - get_major_bounds = slice_locs - - __bounds = None - - @property - def _bounds(self): - """ - Return or compute and return slice points for level 0, assuming - sortedness - """ - if self.__bounds is None: - inds = np.arange(len(self.levels[0])) - self.__bounds = self.labels[0].searchsorted(inds) - - return self.__bounds - def _wrap_joined_index(self, joined, other): names = self.names if self.names == other.names else None return MultiIndex.from_tuples(joined, names=names) diff --git a/pandas/tests/indexes/multi/data/mindex_073.pickle b/pandas/tests/indexes/multi/data/mindex_073.pickle deleted file mode 100644 index c99f51fa289ac..0000000000000 Binary files a/pandas/tests/indexes/multi/data/mindex_073.pickle and /dev/null differ diff --git a/pandas/tests/indexes/multi/data/multiindex_v1.pickle b/pandas/tests/indexes/multi/data/multiindex_v1.pickle deleted file mode 100644 index d404a78f9e397..0000000000000 --- a/pandas/tests/indexes/multi/data/multiindex_v1.pickle +++ /dev/null @@ -1,149 +0,0 @@ -cnumpy.core.multiarray -_reconstruct -p0 -(cpandas.core.index -MultiIndex -p1 -(I0 -tp2 -S'b' -p3 -tp4 -Rp5 -((I1 -(I10 -tp6 -cnumpy -dtype -p7 -(S'O8' -p8 -I0 -I1 -tp9 -Rp10 -(I3 -S'|' -p11 -NNNI-1 -I-1 -I63 -tp12 -bI00 -(lp13 -I0 -aI1 -aI2 -aI3 -aI4 -aI5 -aI6 -aI7 -aI8 -aI9 -atp14 -((lp15 -g0 -(cpandas.core.index -Index -p16 -(I0 -tp17 -g3 -tp18 -Rp19 -((I1 -(I4 -tp20 -g10 -I00 -(lp21 -S'foo' -p22 -aS'bar' -p23 -aS'baz' -p24 -aS'qux' -p25 -atp26 -(S'first' -p27 -tp28 -tp29 -bag0 -(g16 -(I0 -tp30 -g3 -tp31 -Rp32 -((I1 -(I3 -tp33 -g10 -I00 -(lp34 -S'one' -p35 -aS'two' -p36 -aS'three' -p37 -atp38 -(S'second' -p39 -tp40 -tp41 -ba(lp42 -g0 -(cnumpy -ndarray -p43 -(I0 -tp44 -g3 -tp45 -Rp46 -(I1 -(I10 -tp47 -g7 -(S'i4' -p48 -I0 -I1 -tp49 -Rp50 -(I3 -S'<' -p51 -NNNI-1 -I-1 -I0 -tp52 -bI00 -S'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x02\x00\x00\x00\x03\x00\x00\x00\x03\x00\x00\x00\x03\x00\x00\x00' -p53 -tp54 -bag0 -(g43 -(I0 -tp55 -g3 -tp56 -Rp57 -(I1 -(I10 -tp58 -g50 -I00 -S'\x00\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00' -p59 -tp60 -baN(lp61 -g27 -ag39 -atp62 -tp63 -b. \ No newline at end of file diff --git a/pandas/tests/indexes/multi/test_analytics.py b/pandas/tests/indexes/multi/test_analytics.py index 4cc0504417801..9f6a72f803f9d 100644 --- a/pandas/tests/indexes/multi/test_analytics.py +++ b/pandas/tests/indexes/multi/test_analytics.py @@ -15,10 +15,6 @@ def test_shift(idx): pytest.raises(NotImplementedError, idx.shift, 1, 2) -def test_bounds(idx): - idx._bounds - - def test_groupby(idx): groups = idx.groupby(np.array([1, 1, 1, 2, 2, 2])) labels = idx.get_values().tolist() diff --git a/pandas/tests/indexes/multi/test_conversion.py b/pandas/tests/indexes/multi/test_conversion.py index ab99679af0f1a..fcc22390e17a1 100644 --- a/pandas/tests/indexes/multi/test_conversion.py +++ b/pandas/tests/indexes/multi/test_conversion.py @@ -4,10 +4,8 @@ import numpy as np import pandas as pd import pandas.util.testing as tm -import pytest from pandas import DataFrame, MultiIndex, date_range -from pandas.compat import PY3, range -from pandas.util.testing import assert_almost_equal +from pandas.compat import range def test_tolist(idx): @@ -93,46 +91,6 @@ def test_to_hierarchical(): assert result.names == index.names -@pytest.mark.skipif(PY3, reason="testing legacy pickles not support on py3") -def test_legacy_pickle(datapath): - - path = datapath('indexes', 'multi', 'data', 'multiindex_v1.pickle') - obj = pd.read_pickle(path) - - obj2 = MultiIndex.from_tuples(obj.values) - assert obj.equals(obj2) - - res = obj.get_indexer(obj) - exp = np.arange(len(obj), dtype=np.intp) - assert_almost_equal(res, exp) - - res = obj.get_indexer(obj2[::-1]) - exp = obj.get_indexer(obj[::-1]) - exp2 = obj2.get_indexer(obj2[::-1]) - assert_almost_equal(res, exp) - assert_almost_equal(exp, exp2) - - -def test_legacy_v2_unpickle(datapath): - - # 0.7.3 -> 0.8.0 format manage - path = datapath('indexes', 'multi', 'data', 'mindex_073.pickle') - obj = pd.read_pickle(path) - - obj2 = MultiIndex.from_tuples(obj.values) - assert obj.equals(obj2) - - res = obj.get_indexer(obj) - exp = np.arange(len(obj), dtype=np.intp) - assert_almost_equal(res, exp) - - res = obj.get_indexer(obj2[::-1]) - exp = obj.get_indexer(obj[::-1]) - exp2 = obj2.get_indexer(obj2[::-1]) - assert_almost_equal(res, exp) - assert_almost_equal(exp, exp2) - - def test_roundtrip_pickle_with_tz(): # GH 8367 @@ -146,6 +104,7 @@ def test_roundtrip_pickle_with_tz(): def test_pickle(indices): + unpickled = tm.round_trip_pickle(indices) assert indices.equals(unpickled) original_name, indices.name = indices.name, 'foo'