Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate Index.summary #18217

TomAugspurger opened this issue Nov 10, 2017 · 8 comments

Deprecate Index.summary #18217

TomAugspurger opened this issue Nov 10, 2017 · 8 comments


Copy link

@TomAugspurger TomAugspurger commented Nov 10, 2017

In [88]: idx = pd.Index([1, 2, 3])

In [89]: idx.summary()
Out[89]: 'Int64Index: 3 entries, 1 to 3'
@TomAugspurger TomAugspurger added this to the Next Major Release milestone Nov 10, 2017
Copy link

@jreback jreback commented Nov 10, 2017

this is also a useless method and should be deprecated

Copy link

@gfyoung gfyoung commented Nov 10, 2017

Well, Index has no summary methods like .info or .describe (vs. DataFrame or Series). Might be worthwhile to beef this up so that we can return more meaningful info.

Copy link

@jorisvandenbossche jorisvandenbossche commented Nov 13, 2017

I would also deprecate this, and separately we can think whether it is worth to add a info() method to Index?

@TomAugspurger TomAugspurger changed the title Index.summary is undocumented Deprecate Index.summary Nov 13, 2017
Copy link

@punzalan punzalan commented Nov 29, 2017

Apologies if any of this is super naive. I'm new.

Deleting the method and any tests directly targeting it isn't enough. There are other failures like

__ TestDataFrameReprInfoEtc.test_info_duplicate_columns_shows_correct_dtypes ___

self = <pandas.tests.frame.test_repr_info.TestDataFrameReprInfoEtc object at 0x7f34597891d0>

    def test_info_duplicate_columns_shows_correct_dtypes(self):
        # GH11761
        io = StringIO()

        frame = DataFrame([[1, 2.0]],
                          columns=['a', 'a'])
        lines = io.readlines()
>       assert 'a    1 non-null int64\n' == lines[3]
E       AssertionError: assert 'a    1 non-null int64\n' == 'a    1 non-null float64\n'
E         - a    1 non-null int64
E         ?                 ^^
E         + a    1 non-null float64
E         ?                 ^^^^

The reason is the output of summary is included in the output of

In [11]: # pretend the variables in the test are available here

In [12]: lines
["<class 'pandas.core.frame.DataFrame'>\n",
 'RangeIndex: 1 entries, 0 to 0\n',
 'Data columns (total 2 columns):\n',
 'a    1 non-null int64\n',
 'a    1 non-null float64\n',
 'dtypes: float64(1), int64(1)\n',
 'memory usage: 96.0 bytes\n']

(That second element is the output from summary.)

Would it be more appropriate to

  • replace Index.summary with,
  • make info more useful (per above comments), and
  • update tests?

An alternative is to update the tests to make them pass, but I don't know if that's a good idea.

Copy link
Contributor Author

@TomAugspurger TomAugspurger commented Nov 30, 2017

I would

  1. Rename Index.summary to Index._summary
  2. Change anywhere in pandas where we currently use Index.summary to Index._summary
  3. Make a new Index.summary that looks like
def summary(self):
    warnings.warn("Index.summary is deprecated and will be removed in a future version")
    return self._summary()

Copy link

@punzalan punzalan commented Nov 30, 2017

Copy link

@GGordonGordon GGordonGordon commented Mar 5, 2018

@jreback & @TomAugspurger - Are we planning on just deprecating the Index summary method or the DateTimeIndex summary method as well?

Copy link

@jorisvandenbossche jorisvandenbossche commented Mar 5, 2018

@GGordonGordon yes, all Index subclasses would deprecate this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

6 participants