Skip to content

Commit 6cde0b3

Browse files
jschendeljreback
authored andcommitted
DEPR: Remove previously deprecated IntervalIndex.from_intervals (#27793)
1 parent 820e09e commit 6cde0b3

File tree

4 files changed

+1
-89
lines changed

4 files changed

+1
-89
lines changed

doc/source/whatsnew/v1.0.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ Removal of prior version deprecations/changes
6666
- :meth:`pandas.Series.str.cat` now defaults to aligning ``others``, using ``join='left'`` (:issue:`27611`)
6767
- :meth:`pandas.Series.str.cat` does not accept list-likes *within* list-likes anymore (:issue:`27611`)
6868
- Removed the previously deprecated :meth:`ExtensionArray._formatting_values`. Use :attr:`ExtensionArray._formatter` instead. (:issue:`23601`)
69+
- Removed the previously deprecated ``IntervalIndex.from_intervals`` in favor of the :class:`IntervalIndex` constructor (:issue:`19263`)
6970

7071
.. _whatsnew_1000.performance:
7172

pandas/core/arrays/interval.py

-44
Original file line numberDiff line numberDiff line change
@@ -358,50 +358,6 @@ def from_arrays(cls, left, right, closed="right", copy=False, dtype=None):
358358
left, right, closed, copy=copy, dtype=dtype, verify_integrity=True
359359
)
360360

361-
_interval_shared_docs[
362-
"from_intervals"
363-
] = """
364-
Construct an %(klass)s from a 1d array of Interval objects
365-
366-
.. deprecated:: 0.23.0
367-
368-
Parameters
369-
----------
370-
data : array-like (1-dimensional)
371-
Array of Interval objects. All intervals must be closed on the same
372-
sides.
373-
copy : boolean, default False
374-
by-default copy the data, this is compat only and ignored
375-
dtype : dtype or None, default None
376-
If None, dtype will be inferred
377-
378-
..versionadded:: 0.23.0
379-
380-
See Also
381-
--------
382-
interval_range : Function to create a fixed frequency IntervalIndex.
383-
%(klass)s.from_arrays : Construct an %(klass)s from a left and
384-
right array.
385-
%(klass)s.from_breaks : Construct an %(klass)s from an array of
386-
splits.
387-
%(klass)s.from_tuples : Construct an %(klass)s from an
388-
array-like of tuples.
389-
390-
Examples
391-
--------
392-
>>> pd.%(qualname)s.from_intervals([pd.Interval(0, 1),
393-
... pd.Interval(1, 2)])
394-
%(klass)s([(0, 1], (1, 2]],
395-
closed='right', dtype='interval[int64]')
396-
397-
The generic Index constructor work identically when it infers an array
398-
of all intervals:
399-
400-
>>> pd.Index([pd.Interval(0, 1), pd.Interval(1, 2)])
401-
%(klass)s([(0, 1], (1, 2]],
402-
closed='right', dtype='interval[int64]')
403-
"""
404-
405361
_interval_shared_docs[
406362
"from_tuples"
407363
] = """

pandas/core/indexes/interval.py

-16
Original file line numberDiff line numberDiff line change
@@ -269,22 +269,6 @@ def from_arrays(
269269
)
270270
return cls._simple_new(array, name=name)
271271

272-
@classmethod
273-
@Appender(_interval_shared_docs["from_intervals"] % _index_doc_kwargs)
274-
def from_intervals(cls, data, closed=None, name=None, copy=False, dtype=None):
275-
msg = (
276-
"IntervalIndex.from_intervals is deprecated and will be "
277-
"removed in a future version; Use IntervalIndex(...) instead"
278-
)
279-
warnings.warn(msg, FutureWarning, stacklevel=2)
280-
with rewrite_exception("IntervalArray", cls.__name__):
281-
array = IntervalArray(data, closed=closed, copy=copy, dtype=dtype)
282-
283-
if name is None and isinstance(data, cls):
284-
name = data.name
285-
286-
return cls._simple_new(array, name=name)
287-
288272
@classmethod
289273
@Appender(_interval_shared_docs["from_tuples"] % _index_doc_kwargs)
290274
def from_tuples(cls, data, closed="right", name=None, copy=False, dtype=None):

pandas/tests/indexes/interval/test_construction.py

-29
Original file line numberDiff line numberDiff line change
@@ -421,32 +421,3 @@ def test_index_mixed_closed(self):
421421
result = Index(intervals)
422422
expected = Index(intervals, dtype=object)
423423
tm.assert_index_equal(result, expected)
424-
425-
426-
class TestFromIntervals(TestClassConstructors):
427-
"""
428-
Tests for IntervalIndex.from_intervals, which is deprecated in favor of the
429-
IntervalIndex constructor. Same tests as the IntervalIndex constructor,
430-
plus deprecation test. Should only need to delete this class when removed.
431-
"""
432-
433-
@pytest.fixture
434-
def constructor(self):
435-
def from_intervals_ignore_warnings(*args, **kwargs):
436-
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
437-
return IntervalIndex.from_intervals(*args, **kwargs)
438-
439-
return from_intervals_ignore_warnings
440-
441-
def test_deprecated(self):
442-
ivs = [Interval(0, 1), Interval(1, 2)]
443-
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
444-
IntervalIndex.from_intervals(ivs)
445-
446-
@pytest.mark.skip(reason="parent class test that is not applicable")
447-
def test_index_object_dtype(self):
448-
pass
449-
450-
@pytest.mark.skip(reason="parent class test that is not applicable")
451-
def test_index_mixed_closed(self):
452-
pass

0 commit comments

Comments
 (0)