BUG: GH24011 - Rich comparisons of Timestamps now return NotImplemented
State: closed

- [x] closes #24011 
- [x] tests added / passed  (see https://github.com/AlexandreDecan/pandas/blob/fix-24011/pandas/tests/tslibs/test_tslib.py#L26)
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry


Labels:
name: Datetime
description: Datetime data dtype
name: API Design

Comments:
Hello @AlexandreDecan! Thanks for updating this PR. We checked the lines you've touched for [PEP 8](https://www.python.org/dev/peps/pep-0008) issues, and found:



There are currently no PEP 8 issues detected in this Pull Request. Cheers! :beers: 

##### Comment last updated at 2019-04-01 12:13:42 UTC
Tests did not fail locally. I will have a closer look to see why. 
@AlexandreDecan did this become more time-sensitive, or can it still wait until January?
> @AlexandreDecan did this become more time-sensitive, or can it still wait until January?

It can wait until January, I have temporary workarounds. For simplicity, should I close this PR until January?
> For simplicity, should I close this PR until January?

No, it just means I won't feel bad about taking my time to form an opinion.
You should never feel bad about taking time to form an opinion 😉
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24021?src=pr&el=h1) Report
> Merging [#24021](https://codecov.io/gh/pandas-dev/pandas/pull/24021?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/dc8d35aa53d496b651f5e1ab4cb2604e9f7236c7?src=pr&el=desc) will **decrease** coverage by `49.86%`.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/24021/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/24021?src=pr&el=tree)

```diff
@@             Coverage Diff             @@
##           master   #24021       +/-   ##
===========================================
- Coverage   92.31%   42.45%   -49.87%     
===========================================
  Files         161      161               
  Lines       51549    51561       +12     
===========================================
- Hits        47586    21888    -25698     
- Misses       3963    29673    +25710
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `?` | |
| #single | `42.45% <ø> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/24021?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/formats/latex.py](https://codecov.io/gh/pandas-dev/pandas/pull/24021/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvbGF0ZXgucHk=) | `0% <0%> (-100%)` | :arrow_down: |
| [pandas/core/categorical.py](https://codecov.io/gh/pandas-dev/pandas/pull/24021/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvY2F0ZWdvcmljYWwucHk=) | `0% <0%> (-100%)` | :arrow_down: |
| [pandas/io/sas/sas\_constants.py](https://codecov.io/gh/pandas-dev/pandas/pull/24021/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3Nhcy9zYXNfY29uc3RhbnRzLnB5) | `0% <0%> (-100%)` | :arrow_down: |
| [pandas/tseries/plotting.py](https://codecov.io/gh/pandas-dev/pandas/pull/24021/diff?src=pr&el=tree#diff-cGFuZGFzL3RzZXJpZXMvcGxvdHRpbmcucHk=) | `0% <0%> (-100%)` | :arrow_down: |
| [pandas/tseries/converter.py](https://codecov.io/gh/pandas-dev/pandas/pull/24021/diff?src=pr&el=tree#diff-cGFuZGFzL3RzZXJpZXMvY29udmVydGVyLnB5) | `0% <0%> (-100%)` | :arrow_down: |
| [pandas/io/formats/html.py](https://codecov.io/gh/pandas-dev/pandas/pull/24021/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvaHRtbC5weQ==) | `0% <0%> (-97.64%)` | :arrow_down: |
| [pandas/core/groupby/categorical.py](https://codecov.io/gh/pandas-dev/pandas/pull/24021/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ3JvdXBieS9jYXRlZ29yaWNhbC5weQ==) | `0% <0%> (-95.46%)` | :arrow_down: |
| [pandas/io/sas/sas7bdat.py](https://codecov.io/gh/pandas-dev/pandas/pull/24021/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3Nhcy9zYXM3YmRhdC5weQ==) | `0% <0%> (-91.17%)` | :arrow_down: |
| [pandas/io/sas/sas\_xport.py](https://codecov.io/gh/pandas-dev/pandas/pull/24021/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3Nhcy9zYXNfeHBvcnQucHk=) | `0% <0%> (-90.15%)` | :arrow_down: |
| [pandas/core/tools/numeric.py](https://codecov.io/gh/pandas-dev/pandas/pull/24021/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvdG9vbHMvbnVtZXJpYy5weQ==) | `10.44% <0%> (-89.56%)` | :arrow_down: |
| ... and [119 more](https://codecov.io/gh/pandas-dev/pandas/pull/24021/diff?src=pr&el=tree-more) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24021?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24021?src=pr&el=footer). Last update [dc8d35a...1be836d](https://codecov.io/gh/pandas-dev/pandas/pull/24021?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24021?src=pr&el=h1) Report
> Merging [#24021](https://codecov.io/gh/pandas-dev/pandas/pull/24021?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/3989e474eea3d998a25c6219b19333696aca040e?src=pr&el=desc) will **decrease** coverage by `<.01%`.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/24021/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/24021?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #24021      +/-   ##
==========================================
- Coverage   91.82%   91.81%   -0.01%     
==========================================
  Files         175      175              
  Lines       52580    52581       +1     
==========================================
- Hits        48279    48276       -3     
- Misses       4301     4305       +4
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.36% <ø> (ø)` | :arrow_up: |
| #single | `41.89% <ø> (-0.08%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/24021?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/24021/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `75% <0%> (-12.5%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/24021/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `96.79% <0%> (-0.12%)` | :arrow_down: |
| [pandas/\_config/config.py](https://codecov.io/gh/pandas-dev/pandas/pull/24021/diff?src=pr&el=tree#diff-cGFuZGFzL19jb25maWcvY29uZmlnLnB5) | `86.86% <0%> (+0.04%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24021?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24021?src=pr&el=footer). Last update [3989e47...bfda6c3](https://codecov.io/gh/pandas-dev/pandas/pull/24021?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

@jbrockmendel so deferring this to 0.25, can you PR for reverting the Timedelta change.
Closing as stale. Ping if you'd like to continue
Ping!? Waiting for info in #24011
@AlexandreDecan sounds good I've reopened. FWIW this would go in on 0.25 at the earliest at which point we drop Python2 support, so any compat issues there are not really a concern. Briefly read through the rest of the issue and wasn't clear what info you might be waiting for so let me know if I overlooked.

Otherwise feel free to merge master
It wasn't clear to me what is the plan for this issue/PR. I'll add some tests to this PR asap (probably not before tomorrow). 
I forgot that there are already some tests. I'll merge master, and update the what's new entry according to the guidelines (need to find them first ;-)
What about the existing tests that are explicitly failing because of this change? Could I remove/adapt them, or should this be part of another PR? 
I've just fixed the test. Sorry for that, I should have checked before pushing the commits ;-)
Try it out. It may work.

On Tue, Mar 5, 2019 at 5:57 AM Alexandre Decan <notifications@github.com>
wrote:

> *@AlexandreDecan* commented on this pull request.
> ------------------------------
>
> In doc/source/whatsnew/v0.25.0.rst
> <https://github.com/pandas-dev/pandas/pull/24021#discussion_r262466411>:
>
> > @@ -33,6 +33,9 @@ Backwards incompatible API changes
>
>  .. _whatsnew_0250.api_breaking.utc_offset_indexing:
>
> +- Comparing :class:`~Timestamp.Timestamp` with unsupported objects now returns ``NotImplemented`` instead of raising ``TypeError``. This implies that unsupported rich comparisons are delegated to the other object, and is now consistent with Python 3 behavior for ``datetime`` objects (:issue:`24011`)
>
> I think NotImplemented is an object, not a class (see
> https://github.com/python/cpython/blob/4d61e6e3b802399be62a521d6fa785698cb670b5/Objects/object.c#L1730).
> Am I wrong?
>
> —
> You are receiving this because you commented.
> Reply to this email directly, view it on GitHub
> <https://github.com/pandas-dev/pandas/pull/24021#discussion_r262466411>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ABQHIksDQENa8fhBKNWCg9MeqGGdGuPLks5vTluxgaJpZM4Y8HOu>
> .
>

If not, you can include a ref to
https://docs.python.org/3/library/constants.html#NotImplemented

On Tue, Mar 5, 2019 at 6:01 AM Tom Augspurger <tom.augspurger88@gmail.com>
wrote:

> Try it out. It may work.
>
> On Tue, Mar 5, 2019 at 5:57 AM Alexandre Decan <notifications@github.com>
> wrote:
>
>> *@AlexandreDecan* commented on this pull request.
>> ------------------------------
>>
>> In doc/source/whatsnew/v0.25.0.rst
>> <https://github.com/pandas-dev/pandas/pull/24021#discussion_r262466411>:
>>
>> > @@ -33,6 +33,9 @@ Backwards incompatible API changes
>>
>>  .. _whatsnew_0250.api_breaking.utc_offset_indexing:
>>
>> +- Comparing :class:`~Timestamp.Timestamp` with unsupported objects now returns ``NotImplemented`` instead of raising ``TypeError``. This implies that unsupported rich comparisons are delegated to the other object, and is now consistent with Python 3 behavior for ``datetime`` objects (:issue:`24011`)
>>
>> I think NotImplemented is an object, not a class (see
>> https://github.com/python/cpython/blob/4d61e6e3b802399be62a521d6fa785698cb670b5/Objects/object.c#L1730).
>> Am I wrong?
>>
>> —
>> You are receiving this because you commented.
>> Reply to this email directly, view it on GitHub
>> <https://github.com/pandas-dev/pandas/pull/24021#discussion_r262466411>,
>> or mute the thread
>> <https://github.com/notifications/unsubscribe-auth/ABQHIksDQENa8fhBKNWCg9MeqGGdGuPLks5vTluxgaJpZM4Y8HOu>
>> .
>>
>

I tested and it works. Thanks!
can you merge master
Both PY2 ci (#24942) & numpy 1.13 bump (#25554) have been merged. 
Any update for this PR? 
pls merge master
Done.

How many times will I have to merge master? I already did it 12 days ago, when you asked... :)


pr was failing the CI

> How many times will I have to merge master? I already did it 12 days ago, when you asked... :)

we have quite a number of PRs and they are need updating especially when thing change. 12 days is a long time.
@jbrockmendel if you have comments
thanks @AlexandreDecan