Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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