Skip to content

Commit 4119ffb

Browse files
committed
Added docs for Series.dt.freq and removed from ci/code_checks.sh
1 parent 6a7685f commit 4119ffb

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

ci/code_checks.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
7373
-i "pandas.Period.freq GL08" \
7474
-i "pandas.Period.ordinal GL08" \
7575
-i "pandas.RangeIndex.from_range PR01,SA01" \
76-
-i "pandas.Series.dt.freq GL08" \
7776
-i "pandas.Series.dt.unit GL08" \
7877
-i "pandas.Series.pad PR01,SA01" \
7978
-i "pandas.Timedelta.max PR02" \

pandas/core/indexes/accessors.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,32 @@ def to_pydatetime(self) -> Series:
373373

374374
@property
375375
def freq(self):
376+
"""
377+
Tries to return a string representing a frequency generated by infer_freq.
378+
379+
Returns None if it can't autodetect the frequency.
380+
381+
See Also
382+
--------
383+
Series.dt.to_period : Cast to PeriodArray/PeriodIndex at a particular
384+
frequency.
385+
386+
Examples
387+
--------
388+
>>> ser = pd.Series(
389+
... ["2024-01-01", "2024-01-02", "2024-01-03", "2024-01-04"]
390+
... )
391+
>>> ser = pd.to_datetime(ser)
392+
>>> ser.dt.freq
393+
'D'
394+
395+
>>> ser = pd.Series(
396+
... ["2022-01-01", "2024-01-01", "2026-01-01", "2028-01-01"]
397+
... )
398+
>>> ser = pd.to_datetime(ser)
399+
>>> ser.dt.freq
400+
'2YS-JAN'
401+
"""
376402
return self._get_values().inferred_freq
377403

378404
def isocalendar(self) -> DataFrame:

0 commit comments

Comments
 (0)