Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOC: fixing GL08 errors for pandas.IntervalIndex.right and pandas.Series.dt #57732

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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\
Expand Down
38 changes: 38 additions & 0 deletions pandas/core/indexes/accessors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions pandas/core/indexes/interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading