diff --git a/doc/source/v0.14.0.txt b/doc/source/v0.14.0.txt index a484fa3a1f656..bca270856e41b 100644 --- a/doc/source/v0.14.0.txt +++ b/doc/source/v0.14.0.txt @@ -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 ~~~~~~~~~~~ diff --git a/pandas/tseries/index.py b/pandas/tseries/index.py index c58447acec621..26f7cc93e685f 100644 --- a/pandas/tseries/index.py +++ b/pandas/tseries/index.py @@ -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