@@ -20,28 +20,60 @@ cdef class IntervalMixin(object):
20
20
@property
21
21
def closed_left (self ):
22
22
"""
23
- Return True if the Interval is closed on the left-side, else False
23
+ Check if the interval is closed on the left side.
24
+
25
+ For the meaning of `closed` and `open` see :class:`~pandas.Interval`.
26
+
27
+ Returns
28
+ -------
29
+ bool
30
+ ``True`` if the Interval is closed on the left-side, else
31
+ ``False``.
24
32
"""
25
33
return self .closed in (' left' , ' both' )
26
34
27
35
@property
28
36
def closed_right (self ):
29
37
"""
30
- Return True if the Interval is closed on the right-side, else False
38
+ Check if the interval is closed on the right side.
39
+
40
+ For the meaning of `closed` and `open` see :class:`~pandas.Interval`.
41
+
42
+ Returns
43
+ -------
44
+ bool
45
+ ``True`` if the Interval is closed on the left-side, else
46
+ ``False``.
31
47
"""
32
48
return self .closed in (' right' , ' both' )
33
49
34
50
@property
35
51
def open_left (self ):
36
52
"""
37
- Return True if the Interval is open on the left-side, else False
53
+ Check if the interval is open on the left side.
54
+
55
+ For the meaning of `closed` and `open` see :class:`~pandas.Interval`.
56
+
57
+ Returns
58
+ -------
59
+ bool
60
+ ``True`` if the Interval is closed on the left-side, else
61
+ ``False``.
38
62
"""
39
63
return not self .closed_left
40
64
41
65
@property
42
66
def open_right (self ):
43
67
"""
44
- Return True if the Interval is open on the right-side, else False
68
+ Check if the interval is open on the right side.
69
+
70
+ For the meaning of `closed` and `open` see :class:`~pandas.Interval`.
71
+
72
+ Returns
73
+ -------
74
+ bool
75
+ ``True`` if the Interval is closed on the left-side, else
76
+ ``False``.
45
77
"""
46
78
return not self .closed_right
47
79
@@ -88,12 +120,25 @@ cdef class Interval(IntervalMixin):
88
120
closed : {'left', 'right', 'both', 'neither'}, default 'right'
89
121
Whether the interval is closed on the left-side, right-side, both or
90
122
neither.
123
+ closed : {'right', 'left', 'both', 'neither'}, default 'right'
124
+ Whether the interval is closed on the left-side, right-side, both or
125
+ neither. See the Notes for more detailed explanation.
91
126
92
127
Notes
93
128
-----
94
129
The parameters `left` and `right` must be from the same type, you must be
95
130
able to compare them and they must satisfy ``left <= right``.
96
131
132
+ A closed interval (in mathematics denoted by square brackets) contains
133
+ its endpoints, i.e. the closed interval ``[0, 5]`` is characterized by the
134
+ conditions ``0 <= x <= 5``. This is what ``closed='both'`` stands for.
135
+ An open interval (in mathematics denoted by parentheses) does not contain
136
+ its endpoints, i.e. the open interval ``(0, 5)`` is characterized by the
137
+ conditions ``0 < x < 5``. This is what ``closed='neither'`` stands for.
138
+ Intervals can also be half-open or half-closed, i.e. ``[0, 5)`` is
139
+ described by ``0 <= x < 5`` (``closed='left'``) and ``(0, 5]`` is
140
+ described by ``0 < x <= 5`` (``closed='right'``).
141
+
97
142
Examples
98
143
--------
99
144
It is possible to build Intervals of different types, like numeric ones:
@@ -107,12 +152,14 @@ cdef class Interval(IntervalMixin):
107
152
>>> 2.5 in iv
108
153
True
109
154
110
- You can test the bounds
155
+ You can test the bounds (``closed='right'``, so ``0 < x <= 5``):
111
156
112
157
>>> 0 in iv
113
158
False
114
159
>>> 5 in iv
115
160
True
161
+ >>> 0.0001 in iv
162
+ True
116
163
117
164
Calculate its length
118
165
@@ -150,9 +197,10 @@ cdef class Interval(IntervalMixin):
150
197
--------
151
198
IntervalIndex : An Index of Interval objects that are all closed on the
152
199
same side.
153
- cut : Bin values into discrete intervals.
154
- qcut : Discretize values into equal-sized buckets based on rank or
155
- based on sample quantiles.
200
+ cut : Convert continuous data into discrete bins (Categorical
201
+ of Interval objects).
202
+ qcut : Convert continuous data into bins (Categorical of Interval objects)
203
+ based on quantiles.
156
204
Period : Represents a period of time.
157
205
"""
158
206
_typ = " interval"
0 commit comments