Skip to content

Commit fe5a3ef

Browse files
committed
DOC: Modify IntervalArray/IntervalIndex docstrings to pass validate_docstrings.py
1 parent ad2a14f commit fe5a3ef

File tree

2 files changed

+33
-14
lines changed

2 files changed

+33
-14
lines changed

pandas/core/arrays/interval.py

+29-10
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
)
3434

3535

36-
_interval_shared_docs['class'] = """%(summary)s
36+
_interval_shared_docs['class'] = """
37+
%(summary)s
3738
3839
.. versionadded:: %(versionadded)s
3940
@@ -50,13 +51,15 @@
5051
closed : {'left', 'right', 'both', 'neither'}, default 'right'
5152
Whether the intervals are closed on the left-side, right-side, both or
5253
neither.
53-
%(name)s\
54-
copy : boolean, default False
55-
Copy the meta-data.
5654
dtype : dtype or None, default None
57-
If None, dtype will be inferred
55+
If None, dtype will be inferred.
5856
5957
.. versionadded:: 0.23.0
58+
copy : bool, default False
59+
Copy the input data.
60+
%(name)s\
61+
verify_integrity : bool, default True
62+
Verify that the %(klass)s is valid.
6063
6164
Attributes
6265
----------
@@ -87,18 +90,34 @@
8790
See Also
8891
--------
8992
Index : The base pandas Index type
90-
Interval : A bounded slice-like interval; the elements of an IntervalIndex
93+
Interval : A bounded slice-like interval; the elements of an %(klass)s
9194
interval_range : Function to create a fixed frequency IntervalIndex
92-
cut, qcut : Convert arrays of continuous data into Categoricals/Series of
93-
Intervals
95+
cut : Bin values into discrete Intervals
96+
qcut : Bin values into equal-sized Intervals based on rank or sample quantiles
9497
"""
9598

9699

97100
@Appender(_interval_shared_docs['class'] % dict(
98101
klass="IntervalArray",
99-
summary="Pandas array for interval data that are closed on the same side",
102+
summary="Pandas array for interval data that are closed on the same side.",
100103
versionadded="0.24.0",
101-
name='', extra_methods='', examples='',
104+
name='',
105+
extra_methods='',
106+
examples=textwrap.dedent("""\
107+
Examples
108+
--------
109+
A new ``IntervalArray`` can be constructed directly from an array-like of
110+
``Interval`` objects:
111+
112+
>>> pd.core.arrays.IntervalArray([pd.Interval(0, 1), pd.Interval(1, 5)])
113+
IntervalArray([(0, 1], (1, 5]],
114+
closed='right',
115+
dtype='interval[int64]')
116+
117+
It may also be constructed using one of the constructor
118+
methods: :meth:`IntervalArray.from_arrays`,
119+
:meth:`IntervalArray.from_breaks`, and :meth:`IntervalArray.from_tuples`.
120+
"""),
102121
))
103122
@add_metaclass(_WritableDoc)
104123
class IntervalArray(IntervalMixin, ExtensionArray):

pandas/core/indexes/interval.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
target_klass='IntervalIndex or list of Intervals',
5454
name=textwrap.dedent("""\
5555
name : object, optional
56-
to be stored in the index.
56+
Name to be stored in the index.
5757
"""),
5858
))
5959

@@ -116,15 +116,15 @@ def _new_IntervalIndex(cls, d):
116116
versionadded="0.20.0",
117117
extra_methods="contains\n",
118118
examples=textwrap.dedent("""\
119-
120119
Examples
121120
--------
122121
A new ``IntervalIndex`` is typically constructed using
123122
:func:`interval_range`:
124123
125124
>>> pd.interval_range(start=0, end=5)
126-
IntervalIndex([(0, 1], (1, 2], (2, 3], (3, 4], (4, 5]]
127-
closed='right', dtype='interval[int64]')
125+
IntervalIndex([(0, 1], (1, 2], (2, 3], (3, 4], (4, 5]],
126+
closed='right',
127+
dtype='interval[int64]')
128128
129129
It may also be constructed using one of the constructor
130130
methods: :meth:`IntervalIndex.from_arrays`,

0 commit comments

Comments
 (0)