diff --git a/doc/source/api.rst b/doc/source/api.rst index d442d8631247c..e63902a0910b3 100644 --- a/doc/source/api.rst +++ b/doc/source/api.rst @@ -158,6 +158,7 @@ Top-level dealing with datetimelike bdate_range period_range timedelta_range + infer_freq Top-level evaluation ~~~~~~~~~~~~~~~~~~~~ @@ -1364,6 +1365,7 @@ Time/Date Components DatetimeIndex.is_quarter_end DatetimeIndex.is_year_start DatetimeIndex.is_year_end + DatetimeIndex.inferred_freq Selecting ~~~~~~~~~ @@ -1414,6 +1416,7 @@ Components TimedeltaIndex.microseconds TimedeltaIndex.nanoseconds TimedeltaIndex.components + TimedeltaIndex.inferred_freq Conversion ~~~~~~~~~~ diff --git a/pandas/tseries/base.py b/pandas/tseries/base.py index f15de87dbd81c..5f3130bd2dd9c 100644 --- a/pandas/tseries/base.py +++ b/pandas/tseries/base.py @@ -79,6 +79,11 @@ def freqstr(self): @cache_readonly def inferred_freq(self): + """ + Trys to return a string representing a frequency guess, + generated by infer_freq. Returns None if it can't autodetect the + frequency. + """ try: return infer_freq(self) except ValueError: diff --git a/pandas/tseries/frequencies.py b/pandas/tseries/frequencies.py index b220e03fdb327..0e7a9c5b45b0c 100644 --- a/pandas/tseries/frequencies.py +++ b/pandas/tseries/frequencies.py @@ -671,11 +671,11 @@ def _period_str_to_code(freqstr): def infer_freq(index, warn=True): """ Infer the most likely frequency given the input index. If the frequency is - uncertain, a warning will be printed + uncertain, a warning will be printed. Parameters ---------- - index : DatetimeIndex + index : DatetimeIndex or TimedeltaIndex if passed a Series will use the values of the series (NOT THE INDEX) warn : boolean, default True @@ -684,6 +684,7 @@ def infer_freq(index, warn=True): freq : string or None None if no discernible frequency TypeError if the index is not datetime-like + ValueError if there are less than three values. """ import pandas as pd