Skip to content

Commit 3872572

Browse files
authored
DOC: add name parameter to the IntervalIndex for #48911 (#49386)
* DOC: fix #48911, add name parameter to the IntervalIndex * DOC: fix #48911, add name parameter to the IntervalIndex
1 parent 3370c81 commit 3872572

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

doc/source/whatsnew/v2.0.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ Other enhancements
4949
- Fix ``test`` optional_extra by adding missing test package ``pytest-asyncio`` (:issue:`48361`)
5050
- :func:`DataFrame.astype` exception message thrown improved to include column name when type conversion is not possible. (:issue:`47571`)
5151
- :meth:`DataFrame.to_json` now supports a ``mode`` keyword with supported inputs 'w' and 'a'. Defaulting to 'w', 'a' can be used when lines=True and orient='records' to append record oriented json lines to an existing json file. (:issue:`35849`)
52+
- Added ``name`` parameter to :meth:`IntervalIndex.from_breaks`, :meth:`IntervalIndex.from_arrays` and :meth:`IntervalIndex.from_tuples` (:issue:`48911`)
5253

5354
.. ---------------------------------------------------------------------------
5455
.. _whatsnew_200.notable_bug_fixes:

pandas/core/arrays/interval.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,8 @@ def _from_factorized(
383383
Left and right bounds for each interval.
384384
closed : {'left', 'right', 'both', 'neither'}, default 'right'
385385
Whether the intervals are closed on the left-side, right-side, both
386-
or neither.
386+
or neither.\
387+
%(name)s
387388
copy : bool, default False
388389
Copy the data.
389390
dtype : dtype or None, default None
@@ -408,6 +409,7 @@ def _from_factorized(
408409
_interval_shared_docs["from_breaks"]
409410
% {
410411
"klass": "IntervalArray",
412+
"name": "",
411413
"examples": textwrap.dedent(
412414
"""\
413415
Examples
@@ -443,7 +445,8 @@ def from_breaks(
443445
Right bounds for each interval.
444446
closed : {'left', 'right', 'both', 'neither'}, default 'right'
445447
Whether the intervals are closed on the left-side, right-side, both
446-
or neither.
448+
or neither.\
449+
%(name)s
447450
copy : bool, default False
448451
Copy the data.
449452
dtype : dtype, optional
@@ -485,6 +488,7 @@ def from_breaks(
485488
_interval_shared_docs["from_arrays"]
486489
% {
487490
"klass": "IntervalArray",
491+
"name": "",
488492
"examples": textwrap.dedent(
489493
"""\
490494
>>> pd.arrays.IntervalArray.from_arrays([0, 1, 2], [1, 2, 3])
@@ -520,7 +524,8 @@ def from_arrays(
520524
Array of tuples.
521525
closed : {'left', 'right', 'both', 'neither'}, default 'right'
522526
Whether the intervals are closed on the left-side, right-side, both
523-
or neither.
527+
or neither.\
528+
%(name)s
524529
copy : bool, default False
525530
By-default copy the data, this is compat only and ignored.
526531
dtype : dtype or None, default None
@@ -547,6 +552,7 @@ def from_arrays(
547552
_interval_shared_docs["from_tuples"]
548553
% {
549554
"klass": "IntervalArray",
555+
"name": "",
550556
"examples": textwrap.dedent(
551557
"""\
552558
Examples

pandas/core/indexes/interval.py

+15
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,11 @@ def __new__(
236236
_interval_shared_docs["from_breaks"]
237237
% {
238238
"klass": "IntervalIndex",
239+
"name": textwrap.dedent(
240+
"""
241+
name : str, optional
242+
Name of the resulting IntervalIndex."""
243+
),
239244
"examples": textwrap.dedent(
240245
"""\
241246
Examples
@@ -266,6 +271,11 @@ def from_breaks(
266271
_interval_shared_docs["from_arrays"]
267272
% {
268273
"klass": "IntervalIndex",
274+
"name": textwrap.dedent(
275+
"""
276+
name : str, optional
277+
Name of the resulting IntervalIndex."""
278+
),
269279
"examples": textwrap.dedent(
270280
"""\
271281
Examples
@@ -297,6 +307,11 @@ def from_arrays(
297307
_interval_shared_docs["from_tuples"]
298308
% {
299309
"klass": "IntervalIndex",
310+
"name": textwrap.dedent(
311+
"""
312+
name : str, optional
313+
Name of the resulting IntervalIndex."""
314+
),
300315
"examples": textwrap.dedent(
301316
"""\
302317
Examples

0 commit comments

Comments
 (0)