Skip to content

Commit 6d18c14

Browse files
TomAugspurgerPingviinituutti
authored andcommitted
API: Remove IntervalArray from top-level (pandas-dev#24926)
1 parent 38468d1 commit 6d18c14

File tree

8 files changed

+34
-34
lines changed

8 files changed

+34
-34
lines changed

doc/source/reference/arrays.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -288,12 +288,12 @@ Properties
288288
Interval.overlaps
289289
Interval.right
290290

291-
A collection of intervals may be stored in an :class:`IntervalArray`.
291+
A collection of intervals may be stored in an :class:`arrays.IntervalArray`.
292292

293293
.. autosummary::
294294
:toctree: api/
295295

296-
IntervalArray
296+
arrays.IntervalArray
297297
IntervalDtype
298298

299299
.. _api.arrays.integer_na:

doc/source/whatsnew/v0.24.0.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ from the ``Series``:
225225
ser.array
226226
pser.array
227227
228-
These return an instance of :class:`IntervalArray` or :class:`arrays.PeriodArray`,
228+
These return an instance of :class:`arrays.IntervalArray` or :class:`arrays.PeriodArray`,
229229
the new extension arrays that back interval and period data.
230230

231231
.. warning::
@@ -411,7 +411,7 @@ Other Enhancements
411411
- :meth:`Categorical.from_codes` now can take a ``dtype`` parameter as an alternative to passing ``categories`` and ``ordered`` (:issue:`24398`).
412412
- New attribute ``__git_version__`` will return git commit sha of current build (:issue:`21295`).
413413
- Compatibility with Matplotlib 3.0 (:issue:`22790`).
414-
- Added :meth:`Interval.overlaps`, :meth:`IntervalArray.overlaps`, and :meth:`IntervalIndex.overlaps` for determining overlaps between interval-like objects (:issue:`21998`)
414+
- Added :meth:`Interval.overlaps`, :meth:`arrays.IntervalArray.overlaps`, and :meth:`IntervalIndex.overlaps` for determining overlaps between interval-like objects (:issue:`21998`)
415415
- :func:`read_fwf` now accepts keyword ``infer_nrows`` (:issue:`15138`).
416416
- :func:`~DataFrame.to_parquet` now supports writing a ``DataFrame`` as a directory of parquet files partitioned by a subset of the columns when ``engine = 'pyarrow'`` (:issue:`23283`)
417417
- :meth:`Timestamp.tz_localize`, :meth:`DatetimeIndex.tz_localize`, and :meth:`Series.tz_localize` have gained the ``nonexistent`` argument for alternative handling of nonexistent times. See :ref:`timeseries.timezone_nonexistent` (:issue:`8917`, :issue:`24466`)

pandas/core/api.py

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import numpy as np
66

7-
from pandas.core.arrays import IntervalArray
87
from pandas.core.arrays.integer import (
98
Int8Dtype,
109
Int16Dtype,

pandas/core/arrays/array_.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def array(data, # type: Sequence[object]
5050
============================== =====================================
5151
Scalar Type Array Type
5252
============================== =====================================
53-
:class:`pandas.Interval` :class:`pandas.IntervalArray`
53+
:class:`pandas.Interval` :class:`pandas.arrays.IntervalArray`
5454
:class:`pandas.Period` :class:`pandas.arrays.PeriodArray`
5555
:class:`datetime.datetime` :class:`pandas.arrays.DatetimeArray`
5656
:class:`datetime.timedelta` :class:`pandas.arrays.TimedeltaArray`

pandas/core/arrays/interval.py

+15-14
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
_shared_docs_kwargs = dict(
3434
klass='IntervalArray',
35+
qualname='arrays.IntervalArray',
3536
name=''
3637
)
3738

@@ -115,7 +116,7 @@
115116
A new ``IntervalArray`` can be constructed directly from an array-like of
116117
``Interval`` objects:
117118
118-
>>> pd.IntervalArray([pd.Interval(0, 1), pd.Interval(1, 5)])
119+
>>> pd.arrays.IntervalArray([pd.Interval(0, 1), pd.Interval(1, 5)])
119120
IntervalArray([(0, 1], (1, 5]],
120121
closed='right',
121122
dtype='interval[int64]')
@@ -248,8 +249,8 @@ def _from_factorized(cls, values, original):
248249
249250
Examples
250251
--------
251-
>>> pd.%(klass)s.from_breaks([0, 1, 2, 3])
252-
%(klass)s([(0, 1], (1, 2], (2, 3]]
252+
>>> pd.%(qualname)s.from_breaks([0, 1, 2, 3])
253+
%(klass)s([(0, 1], (1, 2], (2, 3]],
253254
closed='right',
254255
dtype='interval[int64]')
255256
"""
@@ -311,7 +312,7 @@ def from_breaks(cls, breaks, closed='right', copy=False, dtype=None):
311312
Examples
312313
--------
313314
>>> %(klass)s.from_arrays([0, 1, 2], [1, 2, 3])
314-
%(klass)s([(0, 1], (1, 2], (2, 3]]
315+
%(klass)s([(0, 1], (1, 2], (2, 3]],
315316
closed='right',
316317
dtype='interval[int64]')
317318
"""
@@ -354,16 +355,16 @@ def from_arrays(cls, left, right, closed='right', copy=False, dtype=None):
354355
355356
Examples
356357
--------
357-
>>> pd.%(klass)s.from_intervals([pd.Interval(0, 1),
358+
>>> pd.%(qualname)s.from_intervals([pd.Interval(0, 1),
358359
... pd.Interval(1, 2)])
359-
%(klass)s([(0, 1], (1, 2]]
360+
%(klass)s([(0, 1], (1, 2]],
360361
closed='right', dtype='interval[int64]')
361362
362363
The generic Index constructor work identically when it infers an array
363364
of all intervals:
364365
365366
>>> pd.Index([pd.Interval(0, 1), pd.Interval(1, 2)])
366-
%(klass)s([(0, 1], (1, 2]]
367+
%(klass)s([(0, 1], (1, 2]],
367368
closed='right', dtype='interval[int64]')
368369
"""
369370

@@ -394,7 +395,7 @@ def from_arrays(cls, left, right, closed='right', copy=False, dtype=None):
394395
395396
Examples
396397
--------
397-
>>> pd.%(klass)s.from_tuples([(0, 1), (1, 2)])
398+
>>> pd.%(qualname)s.from_tuples([(0, 1), (1, 2)])
398399
%(klass)s([(0, 1], (1, 2]],
399400
closed='right', dtype='interval[int64]')
400401
"""
@@ -891,13 +892,13 @@ def closed(self):
891892
892893
Examples
893894
--------
894-
>>> index = pd.interval_range(0, 3)
895-
>>> index
896-
%(klass)s([(0, 1], (1, 2], (2, 3]]
895+
>>> index = pd.interval_range(0, 3)
896+
>>> index
897+
IntervalIndex([(0, 1], (1, 2], (2, 3]],
897898
closed='right',
898899
dtype='interval[int64]')
899-
>>> index.set_closed('both')
900-
%(klass)s([[0, 1], [1, 2], [2, 3]]
900+
>>> index.set_closed('both')
901+
IntervalIndex([[0, 1], [1, 2], [2, 3]],
901902
closed='both',
902903
dtype='interval[int64]')
903904
"""
@@ -1039,7 +1040,7 @@ def repeat(self, repeats, axis=None):
10391040
10401041
Examples
10411042
--------
1042-
>>> intervals = pd.%(klass)s.from_tuples([(0, 1), (1, 3), (2, 4)])
1043+
>>> intervals = pd.%(qualname)s.from_tuples([(0, 1), (1, 3), (2, 4)])
10431044
>>> intervals
10441045
%(klass)s([(0, 1], (1, 3], (2, 4]],
10451046
closed='right',

pandas/core/indexes/interval.py

+12-11
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
_index_doc_kwargs.update(
4040
dict(klass='IntervalIndex',
41+
qualname="IntervalIndex",
4142
target_klass='IntervalIndex or list of Intervals',
4243
name=textwrap.dedent("""\
4344
name : object, optional
@@ -282,10 +283,10 @@ def contains(self, key):
282283
examples="""
283284
Examples
284285
--------
285-
>>> idx = pd.IntervalIndex.from_arrays([0, np.nan, 2], [1, np.nan, 3])
286-
>>> idx.to_tuples()
286+
>>> idx = pd.IntervalIndex.from_arrays([0, np.nan, 2], [1, np.nan, 3])
287+
>>> idx.to_tuples()
287288
Index([(0.0, 1.0), (nan, nan), (2.0, 3.0)], dtype='object')
288-
>>> idx.to_tuples(na_tuple=False)
289+
>>> idx.to_tuples(na_tuple=False)
289290
Index([(0.0, 1.0), nan, (2.0, 3.0)], dtype='object')""",
290291
))
291292
def to_tuples(self, na_tuple=True):
@@ -1201,47 +1202,47 @@ def interval_range(start=None, end=None, periods=None, freq=None,
12011202
Numeric ``start`` and ``end`` is supported.
12021203
12031204
>>> pd.interval_range(start=0, end=5)
1204-
IntervalIndex([(0, 1], (1, 2], (2, 3], (3, 4], (4, 5]]
1205+
IntervalIndex([(0, 1], (1, 2], (2, 3], (3, 4], (4, 5]],
12051206
closed='right', dtype='interval[int64]')
12061207
12071208
Additionally, datetime-like input is also supported.
12081209
12091210
>>> pd.interval_range(start=pd.Timestamp('2017-01-01'),
1210-
end=pd.Timestamp('2017-01-04'))
1211+
... end=pd.Timestamp('2017-01-04'))
12111212
IntervalIndex([(2017-01-01, 2017-01-02], (2017-01-02, 2017-01-03],
1212-
(2017-01-03, 2017-01-04]]
1213+
(2017-01-03, 2017-01-04]],
12131214
closed='right', dtype='interval[datetime64[ns]]')
12141215
12151216
The ``freq`` parameter specifies the frequency between the left and right.
12161217
endpoints of the individual intervals within the ``IntervalIndex``. For
12171218
numeric ``start`` and ``end``, the frequency must also be numeric.
12181219
12191220
>>> pd.interval_range(start=0, periods=4, freq=1.5)
1220-
IntervalIndex([(0.0, 1.5], (1.5, 3.0], (3.0, 4.5], (4.5, 6.0]]
1221+
IntervalIndex([(0.0, 1.5], (1.5, 3.0], (3.0, 4.5], (4.5, 6.0]],
12211222
closed='right', dtype='interval[float64]')
12221223
12231224
Similarly, for datetime-like ``start`` and ``end``, the frequency must be
12241225
convertible to a DateOffset.
12251226
12261227
>>> pd.interval_range(start=pd.Timestamp('2017-01-01'),
1227-
periods=3, freq='MS')
1228+
... periods=3, freq='MS')
12281229
IntervalIndex([(2017-01-01, 2017-02-01], (2017-02-01, 2017-03-01],
1229-
(2017-03-01, 2017-04-01]]
1230+
(2017-03-01, 2017-04-01]],
12301231
closed='right', dtype='interval[datetime64[ns]]')
12311232
12321233
Specify ``start``, ``end``, and ``periods``; the frequency is generated
12331234
automatically (linearly spaced).
12341235
12351236
>>> pd.interval_range(start=0, end=6, periods=4)
1236-
IntervalIndex([(0.0, 1.5], (1.5, 3.0], (3.0, 4.5], (4.5, 6.0]]
1237+
IntervalIndex([(0.0, 1.5], (1.5, 3.0], (3.0, 4.5], (4.5, 6.0]],
12371238
closed='right',
12381239
dtype='interval[float64]')
12391240
12401241
The ``closed`` parameter specifies which endpoints of the individual
12411242
intervals within the ``IntervalIndex`` are closed.
12421243
12431244
>>> pd.interval_range(end=5, periods=4, closed='both')
1244-
IntervalIndex([[1, 2], [2, 3], [3, 4], [4, 5]]
1245+
IntervalIndex([[1, 2], [2, 3], [3, 4], [4, 5]],
12451246
closed='both', dtype='interval[int64]')
12461247
"""
12471248
start = com.maybe_box_datetimelike(start)

pandas/tests/api/test_api.py

-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ class TestPDApi(Base):
4646
'Series', 'SparseArray', 'SparseDataFrame', 'SparseDtype',
4747
'SparseSeries', 'Timedelta',
4848
'TimedeltaIndex', 'Timestamp', 'Interval', 'IntervalIndex',
49-
'IntervalArray',
5049
'CategoricalDtype', 'PeriodDtype', 'IntervalDtype',
5150
'DatetimeTZDtype',
5251
'Int8Dtype', 'Int16Dtype', 'Int32Dtype', 'Int64Dtype',

pandas/tests/arrays/test_array.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
7575
# Interval
7676
([pd.Interval(1, 2), pd.Interval(3, 4)], 'interval',
77-
pd.IntervalArray.from_tuples([(1, 2), (3, 4)])),
77+
pd.arrays.IntervalArray.from_tuples([(1, 2), (3, 4)])),
7878
7979
# Sparse
8080
([0, 1], 'Sparse[int64]', pd.SparseArray([0, 1], dtype='int64')),
@@ -129,7 +129,7 @@ def test_array_copy():
129129
130130
# interval
131131
([pd.Interval(0, 1), pd.Interval(1, 2)],
132-
pd.IntervalArray.from_breaks([0, 1, 2])),
132+
pd.arrays.IntervalArray.from_breaks([0, 1, 2])),
133133
134134
# datetime
135135
([pd.Timestamp('2000',), pd.Timestamp('2001')],

0 commit comments

Comments
 (0)