From a719155b4b93d79d04c0fe5ea7fe55560f96356d Mon Sep 17 00:00:00 2001 From: silviaono Date: Thu, 3 Nov 2022 22:41:16 +0800 Subject: [PATCH] Backport PR #49386: DOC: add name parameter to the IntervalIndex for #48911 --- pandas/core/arrays/interval.py | 12 +++++++++--- pandas/core/indexes/interval.py | 15 +++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/pandas/core/arrays/interval.py b/pandas/core/arrays/interval.py index 8f01dfaf867e7..ea5c6d52f29ba 100644 --- a/pandas/core/arrays/interval.py +++ b/pandas/core/arrays/interval.py @@ -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 @@ -408,6 +409,7 @@ def _from_factorized( _interval_shared_docs["from_breaks"] % { "klass": "IntervalArray", + "name": "", "examples": textwrap.dedent( """\ Examples @@ -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 @@ -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]) @@ -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 @@ -547,6 +552,7 @@ def from_arrays( _interval_shared_docs["from_tuples"] % { "klass": "IntervalArray", + "name": "", "examples": textwrap.dedent( """\ Examples diff --git a/pandas/core/indexes/interval.py b/pandas/core/indexes/interval.py index 92331c9777abb..b18db8b6cb9b9 100644 --- a/pandas/core/indexes/interval.py +++ b/pandas/core/indexes/interval.py @@ -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 @@ -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 @@ -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