Skip to content

inconsistent types resulting from Timestamp arithmetic #6543

Closed
@rosnfeld

Description

@rosnfeld

Adding vs subtracting a datetime.timedelta from a Timestamp yields different return types:

In [1]: timestamp = pd.Timestamp(datetime.datetime(2014, 3, 4))

In [2]: timestamp + datetime.timedelta(seconds=1)
Out[2]: Timestamp('2014-03-04 00:00:01', tz=None)

In [3]: timestamp - datetime.timedelta(seconds=1)
Out[3]: datetime.datetime(2014, 3, 3, 23, 59, 59)

It's an easy fix, I have the code change done and I am just polishing up additional tests to document this behavior and ensure nothing else is broken.

In #4547 I commented I was looking at another issue but hadn't created an issue for it, this is that issue. I realized it's probably better to have an issue, for release notes and the like.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions