Ensure Index._data is an ndarray
State: closed

Split from https://github.com/pandas-dev/pandas/pull/23623, where it was
causing issues.

Labels:
name: Reshaping
description: Concat, Merge/Join, Stack/Unstack, Explode
name: Dtype Conversions
description: Unexpected or buggy dtype conversions

Comments:
Hello @TomAugspurger! Thanks for submitting the PR.

 - There are no PEP8 issues in the file [`pandas/core/indexes/base.py`](https://github.com/TomAugspurger/pandas/blob/1f23ebc92f6c15bf1c2dd7d7a1ddbfc5debd81a2/pandas/core/indexes/base.py) !

 - There are no PEP8 issues in the file [`pandas/tests/indexes/test_base.py`](https://github.com/TomAugspurger/pandas/blob/1f23ebc92f6c15bf1c2dd7d7a1ddbfc5debd81a2/pandas/tests/indexes/test_base.py) !

 - There are no PEP8 issues in the file [`pandas/tests/indexes/test_numeric.py`](https://github.com/TomAugspurger/pandas/blob/1f23ebc92f6c15bf1c2dd7d7a1ddbfc5debd81a2/pandas/tests/indexes/test_numeric.py) !


lgtm. circle seems to be failing lots of PRs today.
I started fixing the callers, but gave up when I saw all the potential call sites. It's not just boolean index, the numeric ones hit this as well.
I didn't look into why the expected failures in 
https://github.com/pandas-dev/pandas/pull/23628/commits/fa8934a3082300c209b4dddc9eb7e34029b6493f changed.
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/23628?src=pr&el=h1) Report
> :exclamation: No coverage uploaded for pull request base (`master@6d031f2`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit).
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff            @@
##             master   #23628   +/-   ##
=========================================
  Coverage          ?   92.24%           
=========================================
  Files             ?      161           
  Lines             ?    51341           
  Branches          ?        0           
=========================================
  Hits              ?    47362           
  Misses            ?     3979           
  Partials          ?        0
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.64% <100%> (?)` | |
| #single | `42.34% <100%> (?)` | |

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

------

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

All green.
> Should we rather fix the places where _simple_new is called with an Index or Series ?

+1 for the "sooner side of eventually" pile
@jbrockmendel can you comment on the skips / expected values in 
https://github.com/pandas-dev/pandas/pull/23628/files/fa8934a3082300c209b4dddc9eb7e34029b6493f#diff-078718e1fe56beae8c2e3be2405f4d19?

It seems to me like the expected values are incorrect. Consider `op=ops.rand_`. In that case, we're saying that

```python
ops.rand_(series, index) -> Series
```

but it seems to me that `ops.and_(index, series) -> Index`, right?

---

edit: just saw your reply.
Based on my thinking in 
https://github.com/pandas-dev/pandas/pull/23628#discussion_r232825815, I've moved the reverse ops to a different test in e4b21f6. Let me know if that seems completely wrong-headed.
Any objections to merging? (this is blocking `IndexOpsMinx.array / to_numpy()`)
@TomAugspurger just to be clear: regarding the behaviour of `xor` with Index / Series, did you decide that the current behaviour is correct? (as you added a test for it)?
To be clear, I added a test for `roxr(Series, Index)`. And if we're using
the most sensible definition of

    roxr(Series, Index) == xor(Index, Series)

then yes, the test should be correct. In that case the expected is
`Index([])`, since they both contained True and False.

On Wed, Nov 14, 2018 at 4:34 AM Joris Van den Bossche <
notifications@github.com> wrote:

> @TomAugspurger <https://github.com/TomAugspurger> just to be clear:
> regarding the behaviour of xor with Index / Series, did you decide that
> the current behaviour is correct? (as you added a test for it)?
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <https://github.com/pandas-dev/pandas/pull/23628#issuecomment-438615798>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ABQHIut2wEt79DaAYgZzvn3fB731C6ykks5uu_GXgaJpZM4YYsIq>
> .
>

parametrized over `indices` (skipping MultiIndex).
All green.
OK for the xor behaviour (We should maybe consider deprecating it, but that's a separate issue)
@TomAugspurger Thanks!