Skip to content

Commit 3aa8778

Browse files
committed
Merge pull request #10053 from jnmclarty/doc_infer_freq
DOC: Add infer frequency to docs
2 parents c6cf596 + 6997368 commit 3aa8778

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

doc/source/api.rst

+3
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ Top-level dealing with datetimelike
158158
bdate_range
159159
period_range
160160
timedelta_range
161+
infer_freq
161162

162163
Top-level evaluation
163164
~~~~~~~~~~~~~~~~~~~~
@@ -1364,6 +1365,7 @@ Time/Date Components
13641365
DatetimeIndex.is_quarter_end
13651366
DatetimeIndex.is_year_start
13661367
DatetimeIndex.is_year_end
1368+
DatetimeIndex.inferred_freq
13671369

13681370
Selecting
13691371
~~~~~~~~~
@@ -1414,6 +1416,7 @@ Components
14141416
TimedeltaIndex.microseconds
14151417
TimedeltaIndex.nanoseconds
14161418
TimedeltaIndex.components
1419+
TimedeltaIndex.inferred_freq
14171420

14181421
Conversion
14191422
~~~~~~~~~~

pandas/tseries/base.py

+5
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ def freqstr(self):
7979

8080
@cache_readonly
8181
def inferred_freq(self):
82+
"""
83+
Trys to return a string representing a frequency guess,
84+
generated by infer_freq. Returns None if it can't autodetect the
85+
frequency.
86+
"""
8287
try:
8388
return infer_freq(self)
8489
except ValueError:

pandas/tseries/frequencies.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -671,11 +671,11 @@ def _period_str_to_code(freqstr):
671671
def infer_freq(index, warn=True):
672672
"""
673673
Infer the most likely frequency given the input index. If the frequency is
674-
uncertain, a warning will be printed
674+
uncertain, a warning will be printed.
675675
676676
Parameters
677677
----------
678-
index : DatetimeIndex
678+
index : DatetimeIndex or TimedeltaIndex
679679
if passed a Series will use the values of the series (NOT THE INDEX)
680680
warn : boolean, default True
681681
@@ -684,6 +684,7 @@ def infer_freq(index, warn=True):
684684
freq : string or None
685685
None if no discernible frequency
686686
TypeError if the index is not datetime-like
687+
ValueError if there are less than three values.
687688
"""
688689
import pandas as pd
689690

0 commit comments

Comments
 (0)