Skip to content

Commit

Permalink
DOC: fixing GL08 errors for pandas.Series.dt (#57751)
Browse files Browse the repository at this point in the history
* fix GL08 error and write docstring for pandas.Series.dt

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* update docstring with parameters

* format docstring and remove from validate docstring ignore

* Remove parameters, returns and add reference

* remove Raises, Notes and update description

* make it pass ci checks

* update see also

* Update ci/code_checks.sh

Co-authored-by: Marc Garcia <[email protected]>

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Marc Garcia <[email protected]>
  • Loading branch information
3 people authored Mar 17, 2024
1 parent 1621ced commit 9eb1553
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 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 Expand Up @@ -437,6 +436,7 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
pandas.Series.cat.rename_categories\
pandas.Series.cat.reorder_categories\
pandas.Series.cat.set_categories\
pandas.Series.dt `# Accessors are implemented as classes, but we do not document the Parameters section` \
pandas.Series.dt.as_unit\
pandas.Series.dt.ceil\
pandas.Series.dt.day_name\
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 @@ -572,6 +572,44 @@ class PeriodProperties(Properties):
class CombinedDatetimelikeProperties(
DatetimeProperties, TimedeltaProperties, PeriodProperties
):
"""
Accessor object for Series values' datetime-like, timedelta and period properties.
See Also
--------
DatetimeIndex : Index of datetime64 data.
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

0 comments on commit 9eb1553

Please sign in to comment.