diff --git a/doc/source/whatsnew/v2.0.0.rst b/doc/source/whatsnew/v2.0.0.rst index 0004bc92b349e..288504c4f2b99 100644 --- a/doc/source/whatsnew/v2.0.0.rst +++ b/doc/source/whatsnew/v2.0.0.rst @@ -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: diff --git a/pandas/core/arrays/interval.py b/pandas/core/arrays/interval.py index 2bc6c9174af81..5e888f4babc95 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 8507280a6cc8d..fa10aee4b6c72 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