Skip to content

Examples in MultiIndex.rename documentation do not call the function #17334

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

Closed
nmusolino opened this issue Aug 25, 2017 · 4 comments
Closed

Examples in MultiIndex.rename documentation do not call the function #17334

nmusolino opened this issue Aug 25, 2017 · 4 comments
Labels

Comments

@nmusolino
Copy link
Contributor

Code Sample

In Pandas version 0.20, The documentation for the function pandas.MultiIndex.rename includes an "Examples" section with five lines of Python code.

Here are the examples:

>>> Index([1, 2, 3, 4]).set_names('foo')
Int64Index([1, 2, 3, 4], dtype='int64')
>>> Index([1, 2, 3, 4]).set_names(['foo'])
Int64Index([1, 2, 3, 4], dtype='int64')
>>> idx = MultiIndex.from_tuples([(1, u'one'), (1, u'two'),
                                  (2, u'one'), (2, u'two')],
                                  names=['foo', 'bar'])
>>> idx.set_names(['baz', 'quz'])
MultiIndex(levels=[[1, 2], [u'one', u'two']],
           labels=[[0, 0, 1, 1], [0, 1, 0, 1]],
           names=[u'baz', u'quz'])
>>> idx.set_names('baz', level=0)
MultiIndex(levels=[[1, 2], [u'one', u'two']],
           labels=[[0, 0, 1, 1], [0, 1, 0, 1]],
           names=[u'baz', u'bar'])

Problem description

The examples do not call the MultiIndex.rename function. Expected contents of the documentation: the examples given for the rename function should actually call the rename function.

Output of pd.show_versions()

N/A, documentation bug.

Meta note

The link above will begin pointing at documentation for a different version of Pandas once the successor to version 0.20 is released as a stable version. Unfortunately, there is no link to version 0.20 documentation per se on the pandas homepage.

@chris-b1
Copy link
Contributor

Thanks, yeah, something strange happening with the sphinx build. The actual docstring is fine, but somehow set_names is being parsed into rename. @jorisvandenbossche ?

https://github.com/pandas-dev/pandas/blob/v0.20.3/pandas/core/indexes/base.py#L1125

@chris-b1 chris-b1 added the Docs label Aug 25, 2017
@jorisvandenbossche
Copy link
Member

If you look at the actual docstring in a console, it is what is shown on the web page. And It is due to this line: https://github.com/pandas-dev/pandas/blob/v0.20.3/pandas/core/indexes/multi.py#L78

So rename is set to set_names, and therefore takes it docstring.

@VincentLa
Copy link
Contributor

Interesting, so in looking at this more deeply, it looks like rename and set_names are equivalent. Is that correct?

@mroeschke
Copy link
Member

Looks like MutiIndex.rename no longer exists, so closing this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants