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.Series.dt #57751

Merged
merged 11 commits into from
Mar 17, 2024
1 change: 0 additions & 1 deletion ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
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
51 changes: 51 additions & 0 deletions pandas/core/indexes/accessors.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,57 @@ 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.
s1099 marked this conversation as resolved.
Show resolved Hide resolved

Raises
------
TypeError
If object is not a pandas Series.
s1099 marked this conversation as resolved.
Show resolved Hide resolved

See Also
--------
Series.dt : Accessor object for datetimelike properties of the Series values.
s1099 marked this conversation as resolved.
Show resolved Hide resolved

Notes
-----
Reference :ref:`Series.dt <series.dt>`
s1099 marked this conversation as resolved.
Show resolved Hide resolved

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

>>> dates = pd.Series(
... ["2024-01-01", "2024-01-15", "2024-02-5"], dtype="datetime64[ns, UTC]"
... )
>>> 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
Loading