pandas.Series.dt.freq#
- Series.dt.freq[source]#
Return a string representing a frequency generated by infer_freq.
Deprecated since version 3.1.0: A future version of pandas will return a
BaseOffsetobject (orNone) instead of a string. Usepd.set_option('future.infer_freq_returns_offset', True)to opt in to the future behavior.Returns None if it can’t autodetect the frequency.
See also
Series.dt.to_periodCast 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'