Skip to content

Troubles with date_range and DST #20596

Closed
@barsanges

Description

@barsanges

Code Sample

>>> pd.date_range('2018-10-23', '2018-11-06', freq='7D', tz='Europe/Paris')
DatetimeIndex(['2018-10-23 00:00:00+02:00', '2018-10-29 23:00:00+01:00', '2018-11-05 23:00:00+01:00'], dtype='datetime64[ns, Europe/Paris]', freq='7D')

>>> pd.date_range('2018-03-25', '2018-04-09', freq='7D', tz='Europe/Paris')
DatetimeIndex(['2018-03-25 00:00:00+01:00', '2018-04-01 01:00:00+02:00', '2018-04-08 01:00:00+02:00'], dtype='datetime64[ns, Europe/Paris]', freq='7D')

Problem description

It seems that the D frequency is somewhat broken around DST dates. The code above gives the same result as pd.date_range(..., freq='168H', tz='Europe/Paris'), but it should be different.

Expected Output

>>> pd.date_range('2018-10-23', '2018-11-06', freq='7D', tz='Europe/Paris')
DatetimeIndex(['2018-10-23 00:00:00+02:00', '2018-10-30 00:00:00+01:00', '2018-11-06 00:00:00+01:00'], dtype='datetime64[ns, Europe/Paris]', freq='7D')

>>> pd.date_range('2018-03-25', '2018-04-09', freq='7D', tz='Europe/Paris')
DatetimeIndex(['2018-03-25 00:00:00+01:00', '2018-04-01 00:00:00+02:00', '2018-04-08 00:00:00+02:00'], dtype='datetime64[ns, Europe/Paris]', freq='7D')

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.6.5.final.0
python-bits: 64
OS: Linux
OS-release: 3.16.0-5-amd64
machine: x86_64
processor:
byteorder: little
LC_ALL: None
LANG: fr_FR.UTF-8
LOCALE: fr_FR.UTF-8

pandas: 0.22.0
pytest: None
pip: 9.0.3
setuptools: 39.0.1
Cython: None
numpy: 1.14.2
scipy: 1.0.1
pyarrow: None
xarray: None
IPython: 6.3.0
sphinx: None
patsy: None
dateutil: 2.7.2
pytz: 2018.3
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 2.2.2
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: None
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Duplicate ReportDuplicate issue or pull requestTimezonesTimezone data dtype

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions