Added extra info section to EA repr
State: closed

Closes https://github.com/pandas-dev/pandas/issues/24278

Labels:
name: Output-Formatting
description: __repr__ of pandas objects, to_string
name: ExtensionArray
description: Extending pandas with custom dtypes or arrays.

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







Cheers ! There are no PEP8 issues in this Pull Request. :beers: 

##### Comment last updated on January 07, 2019 at 15:39 Hours UTC
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24279?src=pr&el=h1) Report
> Merging [#24279](https://codecov.io/gh/pandas-dev/pandas/pull/24279?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/040f06f731a09fc6e0663cada6697f6602b36f1d?src=pr&el=desc) will **increase** coverage by `<.01%`.
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff             @@
##           master   #24279      +/-   ##
==========================================
+ Coverage   92.22%   92.22%   +<.01%     
==========================================
  Files         162      162              
  Lines       51828    51830       +2     
==========================================
+ Hits        47798    47801       +3     
+ Misses       4030     4029       -1
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.62% <100%> (ø)` | :arrow_up: |
| #single | `43% <50%> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/24279?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/arrays/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/24279/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2Jhc2UucHk=) | `97.45% <100%> (+0.03%)` | :arrow_up: |
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/24279/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `87.41% <0%> (-0.1%)` | :arrow_down: |
| [pandas/io/json/json.py](https://codecov.io/gh/pandas-dev/pandas/pull/24279/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2pzb24vanNvbi5weQ==) | `93.09% <0%> (+0.47%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24279?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/24279?src=pr&el=footer). Last update [040f06f...d96942b](https://codecov.io/gh/pandas-dev/pandas/pull/24279?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/24279?src=pr&el=h1) Report
> Merging [#24279](https://codecov.io/gh/pandas-dev/pandas/pull/24279?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/040f06f731a09fc6e0663cada6697f6602b36f1d?src=pr&el=desc) will **increase** coverage by `1.62%`.
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff             @@
##           master   #24279      +/-   ##
==========================================
+ Coverage   92.22%   93.84%   +1.62%     
==========================================
  Files         162      166       +4     
  Lines       51828    70087   +18259     
==========================================
+ Hits        47798    65774   +17976     
- Misses       4030     4313     +283
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `92.5% <100%> (+1.87%)` | :arrow_up: |
| #single | `46.02% <66.66%> (+3.01%)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/24279?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/arrays/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/24279/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2Jhc2UucHk=) | `98% <100%> (+0.58%)` | :arrow_up: |
| [pandas/core/computation/check.py](https://codecov.io/gh/pandas-dev/pandas/pull/24279/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvY29tcHV0YXRpb24vY2hlY2sucHk=) | `87.5% <0%> (-3.41%)` | :arrow_down: |
| [pandas/core/groupby/generic.py](https://codecov.io/gh/pandas-dev/pandas/pull/24279/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ3JvdXBieS9nZW5lcmljLnB5) | `86.16% <0%> (-0.96%)` | :arrow_down: |
| [pandas/core/strings.py](https://codecov.io/gh/pandas-dev/pandas/pull/24279/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvc3RyaW5ncy5weQ==) | `98.58% <0%> (-0.01%)` | :arrow_down: |
| [pandas/core/api.py](https://codecov.io/gh/pandas-dev/pandas/pull/24279/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXBpLnB5) | `100% <0%> (ø)` | :arrow_up: |
| [pandas/core/dtypes/generic.py](https://codecov.io/gh/pandas-dev/pandas/pull/24279/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2dlbmVyaWMucHk=) | `100% <0%> (ø)` | :arrow_up: |
| [pandas/core/internals/\_\_init\_\_.py](https://codecov.io/gh/pandas-dev/pandas/pull/24279/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW50ZXJuYWxzL19faW5pdF9fLnB5) | `100% <0%> (ø)` | :arrow_up: |
| [pandas/core/arrays/\_\_init\_\_.py](https://codecov.io/gh/pandas-dev/pandas/pull/24279/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL19faW5pdF9fLnB5) | `100% <0%> (ø)` | :arrow_up: |
| [pandas/core/arrays/numpy\_.py](https://codecov.io/gh/pandas-dev/pandas/pull/24279/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL251bXB5Xy5weQ==) | `93.51% <0%> (ø)` | |
| [pandas/core/arrays/array\_.py](https://codecov.io/gh/pandas-dev/pandas/pull/24279/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2FycmF5Xy5weQ==) | `100% <0%> (ø)` | |
| ... and [69 more](https://codecov.io/gh/pandas-dev/pandas/pull/24279/diff?src=pr&el=tree-more) | |

------

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

can you do the same for Index
The same what? This is just changing the base ExtensionArray repr.
> The same what? This is just changing the base ExtensionArray repr.

yes, the same, to avoid departing from what we do in Index, which is pretty similar.
Sorry, I'm still not following what you're suggesting.
https://github.com/pandas-dev/pandas/blob/master/pandas/core/indexes/base.py#L929

this is called _format_attrs in Index, so change one or the other
IIUC, `Index._format_attrs` returns a `List[Tuple[str, str]]`. So things like `[('name', self.name), ('dtype', self.dtype)]`

`ExtensionArray._repr_extra` doesn't require key-value pairs. Rather, we just expect a bit of text to include. I don't think it would be appropriate to require key-value pairs here.
> IIUC, Index._format_attrs returns a List[Tuple[str, str]]. So things like [('name', self.name), ('dtype', self.dtype)]

> ExtensionArray._repr_extra doesn't require key-value pairs. Rather, we just expect a bit of text to include. I don't think it would be appropriate to require key-value pairs here

This is just yet another difference with index. I would rather not have these differences.
I could imagine a subclass wanting to include something that's not a key-value pair.
This isn't a priority for me right now. I'd say merge if we think it's an improvement, or close and do it later. Either works for me.
I guess this is fine. ideally just have some integration with Index here (basically use the ``_repr_extra_`` there as well for consistency.
Yes, DatetimeArray should use freq for it.

I don't know which `_attributes` attribute you're referring to. I don't think there's anything like that on ExtensionArray. DatetimeArray defines `_attributes = ['freq', 'tz']`, but the `tz` is already encoded in the dtype.
> I don't know which _attributes attribute you're referring to. I don't think there's anything like that on ExtensionArray. DatetimeArray defines _attributes = ['freq', 'tz'], but the tz is already encoded in the dtype.

Ah, yes, I meant that `_attributes`, but assumed it only had `freq` in it (exactly because `tz` is already in the dtype), but didn't actually check ..
looking again. this is reasonable. can you merge master. are there other places that you see this being used in the current EA's? (other than Decimal).
closing this; I think we need more consolidation on repr to avoid code duplication.