Skip to content

Commit 059b2c1

Browse files
authored
DOC: update docstrings of Interval's attributes (pandas-dev#50609)
1 parent 296cbda commit 059b2c1

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

pandas/_libs/interval.pyx

+68
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,21 @@ cdef class IntervalMixin:
5858
-------
5959
bool
6060
True if the Interval is closed on the left-side.
61+
62+
See Also
63+
--------
64+
Interval.closed_right : Check if the interval is closed on the right side.
65+
Interval.open_left : Boolean inverse of closed_left.
66+
67+
Examples
68+
--------
69+
>>> iv = pd.Interval(0, 5, closed='left')
70+
>>> iv.closed_left
71+
True
72+
73+
>>> iv = pd.Interval(0, 5, closed='right')
74+
>>> iv.closed_left
75+
False
6176
"""
6277
return self.closed in ("left", "both")
6378

@@ -72,6 +87,21 @@ cdef class IntervalMixin:
7287
-------
7388
bool
7489
True if the Interval is closed on the left-side.
90+
91+
See Also
92+
--------
93+
Interval.closed_left : Check if the interval is closed on the left side.
94+
Interval.open_right : Boolean inverse of closed_right.
95+
96+
Examples
97+
--------
98+
>>> iv = pd.Interval(0, 5, closed='both')
99+
>>> iv.closed_right
100+
True
101+
102+
>>> iv = pd.Interval(0, 5, closed='left')
103+
>>> iv.closed_right
104+
False
75105
"""
76106
return self.closed in ("right", "both")
77107

@@ -86,6 +116,21 @@ cdef class IntervalMixin:
86116
-------
87117
bool
88118
True if the Interval is not closed on the left-side.
119+
120+
See Also
121+
--------
122+
Interval.open_right : Check if the interval is open on the right side.
123+
Interval.closed_left : Boolean inverse of open_left.
124+
125+
Examples
126+
--------
127+
>>> iv = pd.Interval(0, 5, closed='neither')
128+
>>> iv.open_left
129+
True
130+
131+
>>> iv = pd.Interval(0, 5, closed='both')
132+
>>> iv.open_left
133+
False
89134
"""
90135
return not self.closed_left
91136

@@ -100,6 +145,21 @@ cdef class IntervalMixin:
100145
-------
101146
bool
102147
True if the Interval is not closed on the left-side.
148+
149+
See Also
150+
--------
151+
Interval.open_left : Check if the interval is open on the left side.
152+
Interval.closed_right : Boolean inverse of open_right.
153+
154+
Examples
155+
--------
156+
>>> iv = pd.Interval(0, 5, closed='left')
157+
>>> iv.open_right
158+
True
159+
160+
>>> iv = pd.Interval(0, 5)
161+
>>> iv.open_right
162+
False
103163
"""
104164
return not self.closed_right
105165

@@ -124,6 +184,10 @@ cdef class IntervalMixin:
124184
def length(self):
125185
"""
126186
Return the length of the Interval.
187+
188+
See Also
189+
--------
190+
Interval.is_empty : Indicates if an interval contains no points.
127191
"""
128192
return self.right - self.left
129193

@@ -140,6 +204,10 @@ cdef class IntervalMixin:
140204
an :class:`~arrays.IntervalArray` or :class:`IntervalIndex` is
141205
empty.
142206
207+
See Also
208+
--------
209+
Interval.length : Return the length of the Interval.
210+
143211
Examples
144212
--------
145213
An :class:`Interval` that contains points is not empty:

0 commit comments

Comments
 (0)