Skip to content

API: offsets.Day should be one calendar day instead of 24 hours #20633

Closed
@mroeschke

Description

@mroeschke

xref issues

As I understand the offset classes, they are supposed to respect transitions in "wall time" instead of absolute time. Currently the Day offset is currently defined to be 24 hours instead of 1 calendar day which is problematic to respect "wall time" wrt DST transitions.

In [25]: foo
Out[25]: Timestamp('2016-10-30 00:00:00+0300', tz='Europe/Helsinki') # DST change on this day

In [26]: foo + pd.tseries.offsets.DateOffset(weeks=1)
Out[26]: Timestamp('2016-11-06 00:00:00+0200', tz='Europe/Helsinki')

In [27]: foo + pd.tseries.offsets.Week()
Out[27]: Timestamp('2016-11-06 00:00:00+0200', tz='Europe/Helsinki') # respects calendar transition

In [28]: foo + pd.Timedelta(weeks=1)
Out[28]: Timestamp('2016-11-05 23:00:00+0200', tz='Europe/Helsinki')

In [29]: foo + pd.tseries.offsets.DateOffset(days=1)
Out[29]: Timestamp('2016-10-31 00:00:00+0200', tz='Europe/Helsinki')

In [30]: foo + pd.tseries.offsets.Day()
Out[30]: Timestamp('2016-10-30 23:00:00+0200', tz='Europe/Helsinki') # does not respects calendar transition

In [31]: foo + pd.Timedelta(days=1)
Out[31]: Timestamp('2016-10-30 23:00:00+0200', tz='Europe/Helsinki')

From prior issues, #20596, #16980, #8774, it seems like many are confused that 1 day = 24 hours when the DST transition comes up and defining 1 day = 1 calendar day would be more intuitive and consistent with other offsets. @

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