Skip to content
Closed
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: 1 addition & 0 deletions doc/source/v0.14.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ Enhancements
and data_label which allow the time stamp and dataset label to be set when creating a
file. (:issue:`6545`)
- ``pandas.io.gbq`` now handles reading unicode strings properly. (:issue:`5940`)
- For a DatetimeIndex ``freq`` always tries to infer a frequency. If it is possible to infer the frequency, viewing the ``inferred_freq`` property of a DatetimeIndex will now also set the offset and freq property as a side effect.

Performance
~~~~~~~~~~~
Expand Down
7 changes: 6 additions & 1 deletion pandas/tseries/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -1421,12 +1421,17 @@ def map(self, f):
@property
def freq(self):
""" return the frequency object if its set, otherwise None """
offset = self.offset
if offset is None:
_ = self.inferred_freq
return self.offset

@cache_readonly
def inferred_freq(self):
try:
return infer_freq(self)
freq = infer_freq(self)
self.offset = to_offset(freq)
return freq
except ValueError:
return None

Expand Down