Skip to content

Commit 318a5a0

Browse files
s1099pre-commit-ci[bot]datapythonista
authored andcommitted
DOC: fixing GL08 errors for pandas.Series.dt (pandas-dev#57751)
* 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]>
1 parent 60873ce commit 318a5a0

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

ci/code_checks.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
155155
pandas.Period.ordinal\
156156
pandas.PeriodIndex.freq\
157157
pandas.PeriodIndex.qyear\
158-
pandas.Series.dt\
159158
pandas.Series.dt.as_unit\
160159
pandas.Series.dt.freq\
161160
pandas.Series.dt.qyear\
@@ -437,6 +436,7 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
437436
pandas.Series.cat.rename_categories\
438437
pandas.Series.cat.reorder_categories\
439438
pandas.Series.cat.set_categories\
439+
pandas.Series.dt `# Accessors are implemented as classes, but we do not document the Parameters section` \
440440
pandas.Series.dt.as_unit\
441441
pandas.Series.dt.ceil\
442442
pandas.Series.dt.day_name\

pandas/core/indexes/accessors.py

+38
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,44 @@ class PeriodProperties(Properties):
572572
class CombinedDatetimelikeProperties(
573573
DatetimeProperties, TimedeltaProperties, PeriodProperties
574574
):
575+
"""
576+
Accessor object for Series values' datetime-like, timedelta and period properties.
577+
578+
See Also
579+
--------
580+
DatetimeIndex : Index of datetime64 data.
581+
582+
Examples
583+
--------
584+
>>> dates = pd.Series(
585+
... ["2024-01-01", "2024-01-15", "2024-02-5"], dtype="datetime64[ns]"
586+
... )
587+
>>> dates.dt.day
588+
0 1
589+
1 15
590+
2 5
591+
dtype: int32
592+
>>> dates.dt.month
593+
0 1
594+
1 1
595+
2 2
596+
dtype: int32
597+
598+
>>> dates = pd.Series(
599+
... ["2024-01-01", "2024-01-15", "2024-02-5"], dtype="datetime64[ns, UTC]"
600+
... )
601+
>>> dates.dt.day
602+
0 1
603+
1 15
604+
2 5
605+
dtype: int32
606+
>>> dates.dt.month
607+
0 1
608+
1 1
609+
2 2
610+
dtype: int32
611+
"""
612+
575613
def __new__(cls, data: Series): # pyright: ignore[reportInconsistentConstructor]
576614
# CombinedDatetimelikeProperties isn't really instantiated. Instead
577615
# we need to choose which parent (datetime or timedelta) is

0 commit comments

Comments
 (0)