Change ._data to ._parent for accessors
State: closed

The idea is to reduce the number of distinct meanings `._data` has.  With this it is down to just `Index._data` and `NDFrame._data`, I think.

Labels:
name: Clean

Comments:
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/21906?src=pr&el=h1) Report
> Merging [#21906](https://codecov.io/gh/pandas-dev/pandas/pull/21906?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/00416816fa5be34567185149fdfcbf2d0e068af0?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `97.67%`.

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

```diff
@@           Coverage Diff           @@
##           master   #21906   +/-   ##
=======================================
  Coverage   92.06%   92.06%           
=======================================
  Files         169      169           
  Lines       50698    50698           
=======================================
  Hits        46675    46675           
  Misses       4023     4023
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.47% <97.67%> (ø)` | :arrow_up: |
| #single | `42.32% <20.93%> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/21906?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/plotting/\_core.py](https://codecov.io/gh/pandas-dev/pandas/pull/21906/diff?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19jb3JlLnB5) | `83.48% <100%> (ø)` | :arrow_up: |
| [pandas/core/indexes/accessors.py](https://codecov.io/gh/pandas-dev/pandas/pull/21906/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9hY2Nlc3NvcnMucHk=) | `90.09% <100%> (ø)` | :arrow_up: |
| [pandas/core/arrays/categorical.py](https://codecov.io/gh/pandas-dev/pandas/pull/21906/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2NhdGVnb3JpY2FsLnB5) | `95.75% <100%> (ø)` | :arrow_up: |
| [pandas/core/strings.py](https://codecov.io/gh/pandas-dev/pandas/pull/21906/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvc3RyaW5ncy5weQ==) | `98.63% <96.96%> (ø)` | :arrow_up: |

------

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

I can see changing this as ``_parent`` is more clear; is it intention to change other uses of ``_data``?
> is it intention to change other uses of _data?

Not really.  At the sprint I brought up the idea of changing BlockManager references from _data to something more distinctive like _mgr, but the reception was luke-warm at best.

There is also #19658 but AFAIK there has been no action on that.
The CI is having unrelated errors here much more consistently than usual.
@mroeschke if you're comfortable with the "Take easy stuff off jreback's plate" strategy, this may qualify.
i don’t think we should do this though

let me look a bit later 
> i don’t think we should do this though

Huh, [here](https://github.com/pandas-dev/pandas/pull/21906#issuecomment-405028499) you seemed on board.  My mistake.

> let me look a bit later

The goal was to take "easy" stuff off your plate.  This is definitely not a priority.
@jbrockmendel hah, right I do remember that now. let me look again. my worry is that we are changing *some* things to ``._parent``, which makes sense, but now we have a dicotomy and now unclear what means what. maybe survey where we use ._data and propose a logical split?
I think using `._parent` for accessors (and *only* for accessors) is a decent start.

Whether we we want to go down the road of changing `Index._data` or `DataFrame._data` can be pursued separately.
> and now unclear what means what.

I think that's @jbrockmendel's reason for changing this in the first place, since `._data` can mean so many things. But with this PR when you need to deal with accessors, or you see `._parent`, you know at a glance what's going on.
yeah I think this change is ok. Just want to document this somewhere and quickly survey other uses for comonaility.
Sounds good. http://pandas-docs.github.io/pandas-docs-travis/internals.html#
may be a decent place for documenting these kinds of relationships between
classes and their data attributes.

On Tue, Aug 7, 2018 at 8:37 AM Jeff Reback <notifications@github.com> wrote:

> yeah I think this change is ok. Just want to document this somewhere and
> quickly survey other uses for comonaility.
>
> —
> You are receiving this because you commented.
> Reply to this email directly, view it on GitHub
> <https://github.com/pandas-dev/pandas/pull/21906#issuecomment-411058777>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ABQHIkvGI6sixHNSxFiTprLqi6DQjCATks5uOZgmgaJpZM4VPl_n>
> .
>

> Just want to document this somewhere and quickly survey other uses for comonaility.

OK, if we're going down this road, should I update `CategoricalAccessor` to use `_parent` instead of `categories`?  (ATM it is the one case that doesn't use `_data`).
yes i am ok with all non internals things changing to use _parent
ok, can you add some docs in internals.rst about this