Closed
Description
Consider the following index crossing a DST transition:
In [1]: import pandas as pd;pd.__version__
Out[1]: '0.15.0'
In [2]: index = pd.date_range(pd.Timestamp("2014-10-25 03:00", tz="Europe/Paris"), periods=10, freq="3H")
In [3]: index
Out[3]:
<class 'pandas.tseries.index.DatetimeIndex'>
[2014-10-25 03:00:00+02:00, ..., 2014-10-26 05:00:00+01:00]
Length: 10, Freq: 3H, Timezone: Europe/Paris
Pandas cannot infer the index frequency:
In [4]: pd.infer_freq(index) is None
Out[4]: True
If we convert the index to UTC, the frequency can be inferred:
In [5]: pd.infer_freq(index.tz_convert("UTC"))
Out[5]: '3H'
If the index does not cross a DST boundary, the frequency can be inferred as well:
In [6]: index = pd.date_range(pd.Timestamp("2014-10-25 03:00", tz="Europe/Paris"), periods=6, freq="3H")
In [7]: index
Out[7]:
<class 'pandas.tseries.index.DatetimeIndex'>
[2014-10-25 03:00:00+02:00, ..., 2014-10-25 18:00:00+02:00]
Length: 6, Freq: 3H, Timezone: Europe/Paris
In [8]: pd.infer_freq(index)
Out[8]: '3H'