Skip to content

'date_range' no longer has a true "24H" frequency #8774

Closed
@broessli

Description

@broessli

The semantic of the frequencies "D" and "24H" in 'date_range' has changed in pandas 0.15.0: they are now both equivalent to a "calendar daily" frequency, ie local time is kept the same across DST transition:

In [1]: import pandas as pd;pd.__version__
Out[1]: '0.15.0'
In [2]: list(pd.date_range(pd.Timestamp("2014-10-24 06:00", tz="Europe/Paris"), periods=4, freq="D"))
Out[2]:
[Timestamp('2014-10-24 06:00:00+0200', tz='Europe/Paris', offset='D'),
 Timestamp('2014-10-25 06:00:00+0200', tz='Europe/Paris', offset='D'),
 Timestamp('2014-10-26 06:00:00+0100', tz='Europe/Paris', offset='D'),
 Timestamp('2014-10-27 06:00:00+0100', tz='Europe/Paris', offset='D')]
In [3]: list(pd.date_range(pd.Timestamp("2014-10-24 06:00", tz="Europe/Paris"), periods=4, freq="24H"))
Out[3]:
[Timestamp('2014-10-24 06:00:00+0200', tz='Europe/Paris', offset='24H'),
 Timestamp('2014-10-25 06:00:00+0200', tz='Europe/Paris', offset='24H'),
 Timestamp('2014-10-26 06:00:00+0100', tz='Europe/Paris', offset='24H'),
 Timestamp('2014-10-27 06:00:00+0100', tz='Europe/Paris', offset='24H')]

But what if we do want a true "24H" frequency ? I think "D" and "24H" should not share the same semantic, Out[2] is OK but Out[3] should be:

[Timestamp('2014-10-24 06:00:00+0200', tz='Europe/Paris'),
 Timestamp('2014-10-25 06:00:00+0200', tz='Europe/Paris'),
 Timestamp('2014-10-26 05:00:00+0100', tz='Europe/Paris'),
 Timestamp('2014-10-27 05:00:00+0100', tz='Europe/Paris')]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions