CLN: remove Index.__inv__ , add Index.__invert__
State: closed

- [x] closes #22335
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry

@jreback @jorisvandenbossche suggestions on where to put a test (``pandas/tests/test_arithmetic.py`` would seem the right place, except it only contains tests involving datetimelike) and which version to target (not sure 0.23.5 is OK)?

Labels:
name: Indexing
description: Related to indexing on series/frames, not to indexes themselves
name: Clean

Comments:
test_arithmetic is ok, pls target 0.24
> which version to target (not sure 0.23.5 is OK)?

In general, if something is not a (critical) bug fix, it should never be considered for a bug fix release (and certainly not something that is more an API clean-up)
> something that is more an API clean-up

Speaking of which, shouldn't we rather deprecate this first before removing?
> shouldn't we rather deprecate this first before removing?

OK, didn't yet read your issue, so missed that `~` is currently not working. Then it is fine removing it without deprecation.
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/22336?src=pr&el=h1) Report
> :exclamation: No coverage uploaded for pull request base (`master@cf70d11`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit).
> The diff coverage is `n/a`.

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

```diff
@@            Coverage Diff            @@
##             master   #22336   +/-   ##
=========================================
  Coverage          ?   92.08%           
=========================================
  Files             ?      169           
  Lines             ?    50704           
  Branches          ?        0           
=========================================
  Hits              ?    46689           
  Misses            ?     4015           
  Partials          ?        0
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.48% <ø> (?)` | |
| #single | `42.33% <ø> (?)` | |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/22336?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/indexes/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/22336/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9iYXNlLnB5) | `96.43% <ø> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/22336?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/22336?src=pr&el=footer). Last update [cf70d11...975e634](https://codecov.io/gh/pandas-dev/pandas/pull/22336?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/22336?src=pr&el=h1) Report
> Merging [#22336](https://codecov.io/gh/pandas-dev/pandas/pull/22336?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/cf70d11a25ec59a5b630921d86759c7fa49884db?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `100%`.

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

```diff
@@           Coverage Diff           @@
##           master   #22336   +/-   ##
=======================================
  Coverage   92.05%   92.05%           
=======================================
  Files         169      169           
  Lines       50709    50709           
=======================================
  Hits        46679    46679           
  Misses       4030     4030
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.46% <100%> (ø)` | :arrow_up: |
| #single | `42.25% <100%> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/22336?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/indexes/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/22336/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9iYXNlLnB5) | `96.43% <100%> (ø)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/22336?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/22336?src=pr&el=footer). Last update [cf70d11...72ebc5d](https://codecov.io/gh/pandas-dev/pandas/pull/22336?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

@jreback @jorisvandenbossche while I was at it, given that this is going to 0.24 anyway, I thought it wouldn't harm to actually enable ``__invert__``, consistently with the case of ``Series``.
@toobaz if you can rebase and check extension arrays
> @toobaz if you can rebase and check extension arrays

@jreback I'm afraid I can do that only in September, but while I'm at it:

> can you add this in conftest as a fixture (unary_op_fixtures)?

In the general ``pandas/conftest.py`` ?

> can you also check that the ops are correctly defined in pandas/core/arrays/base.py (for EA arrays).

Do you mean adding EA arrays to ``box`` fixture? Manually or in some automated way?

(In any case, if some tests fail I would defer to another PR)
closing as stale. if you want to continue, pls merge master and re-open.