diff --git a/doc/source/whatsnew/v1.0.0.rst b/doc/source/whatsnew/v1.0.0.rst index bca7bf8cbefbd..f5ca843e1a6f7 100644 --- a/doc/source/whatsnew/v1.0.0.rst +++ b/doc/source/whatsnew/v1.0.0.rst @@ -66,6 +66,7 @@ Removal of prior version deprecations/changes - :meth:`pandas.Series.str.cat` now defaults to aligning ``others``, using ``join='left'`` (:issue:`27611`) - :meth:`pandas.Series.str.cat` does not accept list-likes *within* list-likes anymore (:issue:`27611`) - Removed the previously deprecated :meth:`ExtensionArray._formatting_values`. Use :attr:`ExtensionArray._formatter` instead. (:issue:`23601`) +- Removed the previously deprecated ``IntervalIndex.from_intervals`` in favor of the :class:`IntervalIndex` constructor (:issue:`19263`) .. _whatsnew_1000.performance: diff --git a/pandas/core/arrays/interval.py b/pandas/core/arrays/interval.py index 2b3c02bd1cade..4ab75090c34d0 100644 --- a/pandas/core/arrays/interval.py +++ b/pandas/core/arrays/interval.py @@ -358,50 +358,6 @@ def from_arrays(cls, left, right, closed="right", copy=False, dtype=None): left, right, closed, copy=copy, dtype=dtype, verify_integrity=True ) - _interval_shared_docs[ - "from_intervals" - ] = """ - Construct an %(klass)s from a 1d array of Interval objects - - .. deprecated:: 0.23.0 - - Parameters - ---------- - data : array-like (1-dimensional) - Array of Interval objects. All intervals must be closed on the same - sides. - copy : boolean, default False - by-default copy the data, this is compat only and ignored - dtype : dtype or None, default None - If None, dtype will be inferred - - ..versionadded:: 0.23.0 - - See Also - -------- - interval_range : Function to create a fixed frequency IntervalIndex. - %(klass)s.from_arrays : Construct an %(klass)s from a left and - right array. - %(klass)s.from_breaks : Construct an %(klass)s from an array of - splits. - %(klass)s.from_tuples : Construct an %(klass)s from an - array-like of tuples. - - Examples - -------- - >>> pd.%(qualname)s.from_intervals([pd.Interval(0, 1), - ... pd.Interval(1, 2)]) - %(klass)s([(0, 1], (1, 2]], - closed='right', dtype='interval[int64]') - - The generic Index constructor work identically when it infers an array - of all intervals: - - >>> pd.Index([pd.Interval(0, 1), pd.Interval(1, 2)]) - %(klass)s([(0, 1], (1, 2]], - closed='right', dtype='interval[int64]') - """ - _interval_shared_docs[ "from_tuples" ] = """ diff --git a/pandas/core/indexes/interval.py b/pandas/core/indexes/interval.py index 7a444683ffcb2..9361408290bb1 100644 --- a/pandas/core/indexes/interval.py +++ b/pandas/core/indexes/interval.py @@ -269,22 +269,6 @@ def from_arrays( ) return cls._simple_new(array, name=name) - @classmethod - @Appender(_interval_shared_docs["from_intervals"] % _index_doc_kwargs) - def from_intervals(cls, data, closed=None, name=None, copy=False, dtype=None): - msg = ( - "IntervalIndex.from_intervals is deprecated and will be " - "removed in a future version; Use IntervalIndex(...) instead" - ) - warnings.warn(msg, FutureWarning, stacklevel=2) - with rewrite_exception("IntervalArray", cls.__name__): - array = IntervalArray(data, closed=closed, copy=copy, dtype=dtype) - - if name is None and isinstance(data, cls): - name = data.name - - return cls._simple_new(array, name=name) - @classmethod @Appender(_interval_shared_docs["from_tuples"] % _index_doc_kwargs) def from_tuples(cls, data, closed="right", name=None, copy=False, dtype=None): diff --git a/pandas/tests/indexes/interval/test_construction.py b/pandas/tests/indexes/interval/test_construction.py index e2abb4531525a..82a10d24dad30 100644 --- a/pandas/tests/indexes/interval/test_construction.py +++ b/pandas/tests/indexes/interval/test_construction.py @@ -421,32 +421,3 @@ def test_index_mixed_closed(self): result = Index(intervals) expected = Index(intervals, dtype=object) tm.assert_index_equal(result, expected) - - -class TestFromIntervals(TestClassConstructors): - """ - Tests for IntervalIndex.from_intervals, which is deprecated in favor of the - IntervalIndex constructor. Same tests as the IntervalIndex constructor, - plus deprecation test. Should only need to delete this class when removed. - """ - - @pytest.fixture - def constructor(self): - def from_intervals_ignore_warnings(*args, **kwargs): - with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): - return IntervalIndex.from_intervals(*args, **kwargs) - - return from_intervals_ignore_warnings - - def test_deprecated(self): - ivs = [Interval(0, 1), Interval(1, 2)] - with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): - IntervalIndex.from_intervals(ivs) - - @pytest.mark.skip(reason="parent class test that is not applicable") - def test_index_object_dtype(self): - pass - - @pytest.mark.skip(reason="parent class test that is not applicable") - def test_index_mixed_closed(self): - pass