Skip to content

Commit

Permalink
DOC: fix docstring validation errors for pandas.Series.dt.freq (panda…
Browse files Browse the repository at this point in the history
…s-dev#60377)

* Added docs for Series.dt.freq and removed from ci/code_checks.sh

* Fix code style
  • Loading branch information
Ivruix authored Nov 20, 2024
1 parent 24df015 commit 72ab3fd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
1 change: 0 additions & 1 deletion ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
-i "pandas.Period.freq GL08" \
-i "pandas.Period.ordinal GL08" \
-i "pandas.RangeIndex.from_range PR01,SA01" \
-i "pandas.Series.dt.freq GL08" \
-i "pandas.Series.dt.unit GL08" \
-i "pandas.Series.pad PR01,SA01" \
-i "pandas.Timedelta.max PR02" \
Expand Down
22 changes: 22 additions & 0 deletions pandas/core/indexes/accessors.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,28 @@ def to_pydatetime(self) -> Series:

@property
def freq(self):
"""
Tries to return a string representing a frequency generated by infer_freq.
Returns None if it can't autodetect the frequency.
See Also
--------
Series.dt.to_period : Cast to PeriodArray/PeriodIndex at a particular
frequency.
Examples
--------
>>> ser = pd.Series(["2024-01-01", "2024-01-02", "2024-01-03", "2024-01-04"])
>>> ser = pd.to_datetime(ser)
>>> ser.dt.freq
'D'
>>> ser = pd.Series(["2022-01-01", "2024-01-01", "2026-01-01", "2028-01-01"])
>>> ser = pd.to_datetime(ser)
>>> ser.dt.freq
'2YS-JAN'
"""
return self._get_values().inferred_freq

def isocalendar(self) -> DataFrame:
Expand Down

0 comments on commit 72ab3fd

Please sign in to comment.