A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pandas-dev/pandas/issues/8772 below:

'infer_freq' does not work with DST transition · Issue #8772 · pandas-dev/pandas · GitHub

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'

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4