Skip to content

BUG: seems that subtracting a YearBegin offset from an index loses the months/days #4804

Closed
@jreback

Description

@jreback

related is #4637 (on freq for WeekDay)

This might be expected, e.g. it conforms the values. or is this a bug?

In [48]: index = date_range('20140101 00:15:00',freq='D',periods=10)
In [44]: df.index.values
Out[44]: 
array(['2013-12-31T19:15:00.000000000-0500',
       '2014-01-01T19:15:00.000000000-0500',
       '2014-01-02T19:15:00.000000000-0500',
       '2014-01-03T19:15:00.000000000-0500',
       '2014-01-04T19:15:00.000000000-0500',
       '2014-01-05T19:15:00.000000000-0500',
       '2014-01-06T19:15:00.000000000-0500',
       '2014-01-07T19:15:00.000000000-0500',
       '2014-01-08T19:15:00.000000000-0500',
       '2014-01-09T19:15:00.000000000-0500'], dtype='datetime64[ns]')

In [46]: (df.index - pd.offsets.YearBegin(1)).values
Out[46]: 
array(['2012-12-31T19:15:00.000000000-0500',
       '2013-12-31T19:15:00.000000000-0500',
       '2013-12-31T19:15:00.000000000-0500',
       '2013-12-31T19:15:00.000000000-0500',
       '2013-12-31T19:15:00.000000000-0500',
       '2013-12-31T19:15:00.000000000-0500',
       '2013-12-31T19:15:00.000000000-0500',
       '2013-12-31T19:15:00.000000000-0500',
       '2013-12-31T19:15:00.000000000-0500',
       '2013-12-31T19:15:00.000000000-0500'], dtype='datetime64[ns]')

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