diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 5bbad800b7aa9..4c4e5cc640843 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -151,12 +151,10 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then pandas.IntervalIndex.left\ pandas.IntervalIndex.length\ pandas.IntervalIndex.mid\ - pandas.IntervalIndex.right\ pandas.Period.freq\ pandas.Period.ordinal\ pandas.PeriodIndex.freq\ pandas.PeriodIndex.qyear\ - pandas.Series.dt\ pandas.Series.dt.as_unit\ pandas.Series.dt.freq\ pandas.Series.dt.qyear\ diff --git a/pandas/core/indexes/accessors.py b/pandas/core/indexes/accessors.py index 5881f5e040370..3dc505134c3d2 100644 --- a/pandas/core/indexes/accessors.py +++ b/pandas/core/indexes/accessors.py @@ -571,6 +571,44 @@ class PeriodProperties(Properties): class CombinedDatetimelikeProperties( DatetimeProperties, TimedeltaProperties, PeriodProperties ): + """ + Combined datetime-like properties for a pandas Series. + + Not meant to be instantiated directly. Instead, used to determine the appropriate + parent class (ArrowTemporalProperties, DatetimeProperties,TimedeltaProperties, + or PeriodProperties) based on the dtype of the provided pandas Series. + + Raises + ------ + TypeError + If object is not a pandas Series. + + Returns + ------- + Instance of the appropriate subclass (ArrowTemporalProperties, + DatetimeProperties, TimedeltaProperties, or PeriodProperties) + + See Also + -------- + pandas.Series.dt : Accessor object for datetimelike properties of the Series values. + + Examples + -------- + >>> dates = pd.Series( + ... ["2024-01-01", "2024-01-15", "2024-02-5"], dtype="datetime64[ns]" + ... ) + >>> dates.dt.day + 0 1 + 1 15 + 2 5 + dtype: int32 + >>> dates.dt.month + 0 1 + 1 1 + 2 2 + dtype: int32 + """ + def __new__(cls, data: Series): # pyright: ignore[reportInconsistentConstructor] # CombinedDatetimelikeProperties isn't really instantiated. Instead # we need to choose which parent (datetime or timedelta) is diff --git a/pandas/core/indexes/interval.py b/pandas/core/indexes/interval.py index ea3e848356ab5..43615bccde2d0 100644 --- a/pandas/core/indexes/interval.py +++ b/pandas/core/indexes/interval.py @@ -831,6 +831,25 @@ def left(self) -> Index: @cache_readonly def right(self) -> Index: + """ + Return intervals' right value. + + Returns + ------- + Index + + See Also + -------- + IntervalIndex : The structure of IntervalIndex. + + Examples + -------- + >>> pd.interval_range(start=0, end=5) + IntervalIndex([(0, 1], (1, 2], (2, 3], (3, 4], (4, 5]], + dtype='interval[int64, right]') + >>> pd.interval_range(start=0, end=5).right + Index([1, 2, 3, 4, 5], dtype='int64') + """ return Index(self._data.right, copy=False) @cache_readonly