Feature/groupby repr ellipses 1135
State: closed

- [ ] closes #1135 
- [ ] tests added / passed
- [ ] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [ ] whatsnew entry

Currently one test is failing:

```
    def test_groups(self, df):
        grouped = df.groupby(['A'])
        groups = grouped.groups
        assert groups is grouped.groups  # caching works
```

I'm not sure what exactly this test is checking for. Is this a behavior that needs to be kept?

Labels:
name: Groupby
name: Output-Formatting
description: __repr__ of pandas objects, to_string

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

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

```diff
@@            Coverage Diff             @@
##           master   #24853      +/-   ##
==========================================
- Coverage   91.98%   91.97%   -0.01%     
==========================================
  Files         175      175              
  Lines       52372    52375       +3     
==========================================
- Hits        48172    48171       -1     
- Misses       4200     4204       +4
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.52% <100%> (ø)` | :arrow_up: |
| #single | `40.7% <75%> (-0.14%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/24853?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/groupby/groupby.py](https://codecov.io/gh/pandas-dev/pandas/pull/24853/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ3JvdXBieS9ncm91cGJ5LnB5) | `97.23% <ø> (ø)` | :arrow_up: |
| [pandas/io/formats/printing.py](https://codecov.io/gh/pandas-dev/pandas/pull/24853/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvcHJpbnRpbmcucHk=) | `86.09% <ø> (+0.53%)` | :arrow_up: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/24853/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `96.9% <ø> (-0.12%)` | :arrow_down: |
| [pandas/core/groupby/grouper.py](https://codecov.io/gh/pandas-dev/pandas/pull/24853/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ3JvdXBieS9ncm91cGVyLnB5) | `98.18% <ø> (ø)` | :arrow_up: |
| [pandas/core/groupby/ops.py](https://codecov.io/gh/pandas-dev/pandas/pull/24853/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ3JvdXBieS9vcHMucHk=) | `95.97% <ø> (ø)` | :arrow_up: |
| [pandas/core/indexes/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/24853/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9iYXNlLnB5) | `96.94% <100%> (ø)` | :arrow_up: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/24853/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `78.94% <0%> (-10.53%)` | :arrow_down: |
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/24853/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `90.61% <0%> (-0.11%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24853?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/24853?src=pr&el=footer). Last update [48ea04f...9742473](https://codecov.io/gh/pandas-dev/pandas/pull/24853?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/24853?src=pr&el=h1) Report
> Merging [#24853](https://codecov.io/gh/pandas-dev/pandas/pull/24853?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/01e7872b018f8ceb1c5d1217caf03d5ba4da3602?src=pr&el=desc) will **decrease** coverage by `49.49%`.
> The diff coverage is `23.07%`.

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

```diff
@@            Coverage Diff             @@
##           master   #24853      +/-   ##
==========================================
- Coverage   92.39%   42.89%   -49.5%     
==========================================
  Files         166      166              
  Lines       52391    52398       +7     
==========================================
- Hits        48407    22477   -25930     
- Misses       3984    29921   +25937
```

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

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/24853?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/24853/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `35.84% <ø> (-61.08%)` | :arrow_down: |
| [pandas/io/formats/printing.py](https://codecov.io/gh/pandas-dev/pandas/pull/24853/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvcHJpbnRpbmcucHk=) | `65.15% <10%> (-20.27%)` | :arrow_down: |
| [pandas/core/groupby/groupby.py](https://codecov.io/gh/pandas-dev/pandas/pull/24853/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ3JvdXBieS9ncm91cGJ5LnB5) | `24.62% <66.66%> (-72.19%)` | :arrow_down: |
| [pandas/io/formats/latex.py](https://codecov.io/gh/pandas-dev/pandas/pull/24853/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvbGF0ZXgucHk=) | `0% <0%> (-100%)` | :arrow_down: |
| [pandas/core/categorical.py](https://codecov.io/gh/pandas-dev/pandas/pull/24853/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/24853/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3Nhcy9zYXNfY29uc3RhbnRzLnB5) | `0% <0%> (-100%)` | :arrow_down: |
| [pandas/tseries/plotting.py](https://codecov.io/gh/pandas-dev/pandas/pull/24853/diff?src=pr&el=tree#diff-cGFuZGFzL3RzZXJpZXMvcGxvdHRpbmcucHk=) | `0% <0%> (-100%)` | :arrow_down: |
| [pandas/tseries/converter.py](https://codecov.io/gh/pandas-dev/pandas/pull/24853/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/24853/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvaHRtbC5weQ==) | `0% <0%> (-99.35%)` | :arrow_down: |
| [pandas/core/groupby/categorical.py](https://codecov.io/gh/pandas-dev/pandas/pull/24853/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ3JvdXBieS9jYXRlZ29yaWNhbC5weQ==) | `0% <0%> (-95.46%)` | :arrow_down: |
| ... and [126 more](https://codecov.io/gh/pandas-dev/pandas/pull/24853/diff?src=pr&el=tree-more) | |

------

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

@benarthur91 can you check failures on this one?
Pushing w/ failing test commented out - I don't understand the issue well, and want to confirm this test is the reason for red from Codecov before addressing.
@benarthur91 any chance you can merge master and refactor to go another route? I'm personally -1 on current implementation due to instantiation of new object on property access as I think that's just a confusing API
@WillAyd Definitely. Did you have a particular alternative in mind? I was thinking to make the underlying object an instance of the class, but if you have a thought I'd love to hear it.
Not particularly

> On Feb 11, 2019, at 9:59 PM, benarthur91 <notifications@github.com> wrote:
> 
> @WillAyd <https://github.com/WillAyd> Definitely. Did you have a particular alternative in mind? I was thinking to make the underlying object an instance of the class, but if you have a thought I'd love to hear 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/24853#issuecomment-462627552>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAlOUUdFj7iNYnL3C4EcXsuiqUf9ab4uks5vMlhYgaJpZM4aJ7ao>.
> 


@jreback I've updated to use pprint_thing. I believe the desired output is something like

`{1: Int64Index([0, 1, 2], dtype='int64'), ... , 3: Int64Index([5], dtype='int64')}`

but with the use of this function I get:

`{1: [0, 1, ...], 2: [3, 4], ...}`

However this abbreviates at the end of the object rather than the middle (not consistent with DataFrame's repr) and the pprint behavior is applied recursively, so reprs of the object's values are oversimplified. I attempted to address these issues on commit 19bb9bf, however this required changes to the pprint_thing definition.
can you merge master and see if you can get this passing
can you merge master and update
closing as stale, but this is pretty close if you or @pandas-dev/pandas-core would like to finish up.