Skip to content

DOC: add name parameter to the IntervalIndex for #48911 #49386

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/v2.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Other enhancements
- Fix ``test`` optional_extra by adding missing test package ``pytest-asyncio`` (:issue:`48361`)
- :func:`DataFrame.astype` exception message thrown improved to include column name when type conversion is not possible. (:issue:`47571`)
- :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`)
- Added ``name`` parameter to :meth:`IntervalIndex.from_breaks`, :meth:`IntervalIndex.from_arrays` and :meth:`IntervalIndex.from_tuples` (:issue:`48911`)

.. ---------------------------------------------------------------------------
.. _whatsnew_200.notable_bug_fixes:
Expand Down
12 changes: 9 additions & 3 deletions pandas/core/arrays/interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,8 @@ def _from_factorized(
Left and right bounds for each interval.
closed : {'left', 'right', 'both', 'neither'}, default 'right'
Whether the intervals are closed on the left-side, right-side, both
or neither.
or neither.\
%(name)s
copy : bool, default False
Copy the data.
dtype : dtype or None, default None
Expand All @@ -408,6 +409,7 @@ def _from_factorized(
_interval_shared_docs["from_breaks"]
% {
"klass": "IntervalArray",
"name": "",
"examples": textwrap.dedent(
"""\
Examples
Expand Down Expand Up @@ -443,7 +445,8 @@ def from_breaks(
Right bounds for each interval.
closed : {'left', 'right', 'both', 'neither'}, default 'right'
Whether the intervals are closed on the left-side, right-side, both
or neither.
or neither.\
%(name)s
copy : bool, default False
Copy the data.
dtype : dtype, optional
Expand Down Expand Up @@ -485,6 +488,7 @@ def from_breaks(
_interval_shared_docs["from_arrays"]
% {
"klass": "IntervalArray",
"name": "",
"examples": textwrap.dedent(
"""\
>>> pd.arrays.IntervalArray.from_arrays([0, 1, 2], [1, 2, 3])
Expand Down Expand Up @@ -520,7 +524,8 @@ def from_arrays(
Array of tuples.
closed : {'left', 'right', 'both', 'neither'}, default 'right'
Whether the intervals are closed on the left-side, right-side, both
or neither.
or neither.\
%(name)s
copy : bool, default False
By-default copy the data, this is compat only and ignored.
dtype : dtype or None, default None
Expand All @@ -547,6 +552,7 @@ def from_arrays(
_interval_shared_docs["from_tuples"]
% {
"klass": "IntervalArray",
"name": "",
"examples": textwrap.dedent(
"""\
Examples
Expand Down
15 changes: 15 additions & 0 deletions pandas/core/indexes/interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,11 @@ def __new__(
_interval_shared_docs["from_breaks"]
% {
"klass": "IntervalIndex",
"name": textwrap.dedent(
"""
name : str, optional
Name of the resulting IntervalIndex."""
),
"examples": textwrap.dedent(
"""\
Examples
Expand Down Expand Up @@ -266,6 +271,11 @@ def from_breaks(
_interval_shared_docs["from_arrays"]
% {
"klass": "IntervalIndex",
"name": textwrap.dedent(
"""
name : str, optional
Name of the resulting IntervalIndex."""
),
"examples": textwrap.dedent(
"""\
Examples
Expand Down Expand Up @@ -297,6 +307,11 @@ def from_arrays(
_interval_shared_docs["from_tuples"]
% {
"klass": "IntervalIndex",
"name": textwrap.dedent(
"""
name : str, optional
Name of the resulting IntervalIndex."""
),
"examples": textwrap.dedent(
"""\
Examples
Expand Down