Skip to content

Commit a7153da

Browse files
committed
2 parents 1e1ea93 + 529bcc1 commit a7153da

File tree

5 files changed

+65
-17
lines changed

5 files changed

+65
-17
lines changed

ci/code_checks.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
7676
-i "pandas.DataFrame.min RT03" \
7777
-i "pandas.DataFrame.plot PR02,SA01" \
7878
-i "pandas.Grouper PR02" \
79-
-i "pandas.Index PR07" \
80-
-i "pandas.IntervalIndex.left GL08" \
81-
-i "pandas.IntervalIndex.set_closed RT03,SA01" \
8279
-i "pandas.MultiIndex PR01" \
8380
-i "pandas.MultiIndex.append PR07,SA01" \
8481
-i "pandas.MultiIndex.copy PR07,RT03,SA01" \
@@ -247,7 +244,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
247244
-i "pandas.Series.truediv PR07" \
248245
-i "pandas.Series.update PR07,SA01" \
249246
-i "pandas.Series.var PR01,RT03,SA01" \
250-
-i "pandas.SparseDtype SA01" \
251247
-i "pandas.Timedelta PR07,SA01" \
252248
-i "pandas.Timedelta.as_unit SA01" \
253249
-i "pandas.Timedelta.asm8 SA01" \
@@ -396,7 +392,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
396392
-i "pandas.arrays.IntervalArray.length SA01" \
397393
-i "pandas.arrays.IntervalArray.mid SA01" \
398394
-i "pandas.arrays.IntervalArray.right SA01" \
399-
-i "pandas.arrays.IntervalArray.set_closed RT03,SA01" \
400395
-i "pandas.arrays.NumpyExtensionArray SA01" \
401396
-i "pandas.arrays.SparseArray PR07,SA01" \
402397
-i "pandas.arrays.TimedeltaArray PR07,SA01" \

pandas/core/arrays/interval.py

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,28 +1436,38 @@ def closed(self) -> IntervalClosedType:
14361436
"""
14371437
)
14381438

1439-
@Appender(
1440-
_interval_shared_docs["set_closed"]
1441-
% {
1442-
"klass": "IntervalArray",
1443-
"examples": textwrap.dedent(
1444-
"""\
1439+
def set_closed(self, closed: IntervalClosedType) -> Self:
1440+
"""
1441+
Return an identical IntervalArray closed on the specified side.
1442+
1443+
Parameters
1444+
----------
1445+
closed : {'left', 'right', 'both', 'neither'}
1446+
Whether the intervals are closed on the left-side, right-side, both
1447+
or neither.
1448+
1449+
Returns
1450+
-------
1451+
IntervalArray
1452+
A new IntervalArray with the specified side closures.
1453+
1454+
See Also
1455+
--------
1456+
IntervalArray.closed : Returns inclusive side of the Interval.
1457+
arrays.IntervalArray.closed : Returns inclusive side of the IntervalArray.
1458+
14451459
Examples
14461460
--------
14471461
>>> index = pd.arrays.IntervalArray.from_breaks(range(4))
14481462
>>> index
14491463
<IntervalArray>
14501464
[(0, 1], (1, 2], (2, 3]]
14511465
Length: 3, dtype: interval[int64, right]
1452-
>>> index.set_closed('both')
1466+
>>> index.set_closed("both")
14531467
<IntervalArray>
14541468
[[0, 1], [1, 2], [2, 3]]
14551469
Length: 3, dtype: interval[int64, both]
14561470
"""
1457-
),
1458-
}
1459-
)
1460-
def set_closed(self, closed: IntervalClosedType) -> Self:
14611471
if closed not in VALID_CLOSED:
14621472
msg = f"invalid option for 'closed': {closed}"
14631473
raise ValueError(msg)

pandas/core/dtypes/dtypes.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1665,7 +1665,10 @@ class SparseDtype(ExtensionDtype):
16651665
"""
16661666
Dtype for data stored in :class:`SparseArray`.
16671667
1668-
This dtype implements the pandas ExtensionDtype interface.
1668+
`SparseDtype` is used as the data type for :class:`SparseArray`, enabling
1669+
more efficient storage of data that contains a significant number of
1670+
repetitive values typically represented by a fill value. It supports any
1671+
scalar dtype as the underlying data type of the non-fill values.
16691672
16701673
Parameters
16711674
----------
@@ -1695,6 +1698,11 @@ class SparseDtype(ExtensionDtype):
16951698
-------
16961699
None
16971700
1701+
See Also
1702+
--------
1703+
arrays.SparseArray : The array structure that uses SparseDtype
1704+
for data representation.
1705+
16981706
Examples
16991707
--------
17001708
>>> ser = pd.Series([1, 0, 0], dtype=pd.SparseDtype(dtype=int, fill_value=0))

pandas/core/indexes/base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,8 @@ class Index(IndexOpsMixin, PandasObject):
326326
Parameters
327327
----------
328328
data : array-like (1-dimensional)
329+
An array-like structure containing the data for the index. This could be a
330+
Python list, a NumPy array, or a pandas Series.
329331
dtype : str, numpy.dtype, or ExtensionDtype, optional
330332
Data type for the output Index. If not specified, this will be
331333
inferred from `data`.

pandas/core/indexes/interval.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,39 @@ def _is_comparable_dtype(self, dtype: DtypeObj) -> bool:
842842

843843
@cache_readonly
844844
def left(self) -> Index:
845+
"""
846+
Return left bounds of the intervals in the IntervalIndex.
847+
848+
The left bounds of each interval in the IntervalIndex are
849+
returned as an Index. The datatype of the left bounds is the
850+
same as the datatype of the endpoints of the intervals.
851+
852+
Returns
853+
-------
854+
Index
855+
An Index containing the left bounds of the intervals.
856+
857+
See Also
858+
--------
859+
IntervalIndex.right : Return the right bounds of the intervals
860+
in the IntervalIndex.
861+
IntervalIndex.mid : Return the mid-point of the intervals in
862+
the IntervalIndex.
863+
IntervalIndex.length : Return the length of the intervals in
864+
the IntervalIndex.
865+
866+
Examples
867+
--------
868+
>>> iv_idx = pd.IntervalIndex.from_arrays([1, 2, 3], [4, 5, 6], closed="right")
869+
>>> iv_idx.left
870+
Index([1, 2, 3], dtype='int64')
871+
872+
>>> iv_idx = pd.IntervalIndex.from_tuples(
873+
... [(1, 4), (2, 5), (3, 6)], closed="left"
874+
... )
875+
>>> iv_idx.left
876+
Index([1, 2, 3], dtype='int64')
877+
"""
845878
return Index(self._data.left, copy=False)
846879

847880
@cache_readonly

0 commit comments

Comments
 (0)