Skip to content

DOC: update pandas.Series.rename_axis #20137

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

Merged
merged 2 commits into from
Mar 13, 2018

Conversation

xrmx
Copy link
Contributor

@xrmx xrmx commented Mar 10, 2018

Checklist for the pandas documentation sprint (ignore this if you are doing
an unrelated PR):

  • PR title is "DOC: update the docstring"
  • The validation script passes: scripts/validate_docstrings.py <your-function-or-method>
  • The PEP8 style check passes: git diff upstream/master -u -- "*.py" | flake8 --diff
  • The html version looks good: python doc/make.py --single <your-function-or-method>
  • It has been proofread on language by another sprint participant

Please include the output of the validation script below between the "```" ticks:

################################################################################
############# Docstring (pandas.core.generic.NDFrame.rename_axis)  #############
################################################################################

Alter the name of the index or columns.

This function alters the name of the index or columns.

Parameters
----------
mapper : scalar, list-like, optional
    Value to set the axis name attribute.
axis : int, str, default 0
    The index or the name of the axis.
copy : boolean, default True
    Also copy underlying data.
inplace : boolean, default False
    Modifies the mapper in place.

Returns
-------
type of caller or None if inplace=True
    Renamed

Notes
-----
Prior to version 0.21.0, ``rename_axis`` could also be used to change
the axis *labels* by passing a mapping or scalar. This behavior is
deprecated and will be removed in a future version. Use ``rename``
instead.

See Also
--------
pandas.Series.rename : Alter Series index labels or name
pandas.DataFrame.rename : Alter DataFrame index labels or name
pandas.Index.rename : Set new names on index

Examples
--------
>>> df = pd.DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]})
>>> df.rename_axis("foo")
     A  B
foo
0    1  4
1    2  5
2    3  6

>>> df.rename_axis("bar", axis="columns")
bar  A  B
0    1  4
1    2  5
2    3  6

################################################################################
################################## Validation ##################################
################################################################################

Docstring for "pandas.core.generic.NDFrame.rename_axis" correct. :)

"""
Alter the name of the index or columns.

This function alters the name of the index or columns.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is just restating the short summary I think it can be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


Parameters
----------
mapper : scalar, list-like, optional
Value to set the axis name attribute.
axis : int or string, default 0
axis : int, str, default 0
The index or the name of the axis.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where inconsistent with axis. But

        axis : {0 or 'index', 1 or 'columns'}, default 0

seems to be the most common.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


Returns
-------
renamed : type of caller or None if inplace=True
type of caller or None if inplace=True
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be

renamed : Series, DataFrame, or None
    The same type as the caller or None if `inplace` is True.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@xrmx xrmx force-pushed the docstringrenameaxis branch from d34d2b6 to c1e91f9 Compare March 10, 2018 14:18
@xrmx
Copy link
Contributor Author

xrmx commented Mar 10, 2018

Updated PR after review, thanks!

[ci skip]
@codecov
Copy link

codecov bot commented Mar 13, 2018

Codecov Report

Merging #20137 into master will decrease coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #20137      +/-   ##
==========================================
- Coverage   91.72%   91.72%   -0.01%     
==========================================
  Files         150      150              
  Lines       49156    49152       -4     
==========================================
- Hits        45090    45086       -4     
  Misses       4066     4066
Flag Coverage Δ
#multiple 90.11% <ø> (-0.01%) ⬇️
#single 41.84% <ø> (-0.01%) ⬇️
Impacted Files Coverage Δ
pandas/core/generic.py 95.84% <ø> (ø) ⬆️
pandas/core/base.py 96.78% <0%> (-0.02%) ⬇️
pandas/core/series.py 93.85% <0%> (-0.01%) ⬇️
pandas/core/indexes/base.py 96.66% <0%> (-0.01%) ⬇️
pandas/core/indexes/multi.py 95.06% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 840d432...9d6755f. Read the comment docs.

@TomAugspurger
Copy link
Contributor

Added a series example. Thanks @xrmx!

@TomAugspurger TomAugspurger merged commit 76a87ca into pandas-dev:master Mar 13, 2018
@TomAugspurger TomAugspurger added this to the 0.23.0 milestone Mar 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants