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

move rename functionality out of internals #21924

Merged
merged 9 commits into from
Sep 8, 2018

Conversation

jbrockmendel
Copy link
Member

@jbrockmendel jbrockmendel commented Jul 15, 2018

@jorisvandenbossche can you confirm this is what you had in mind in that issue?

@codecov
Copy link

codecov bot commented Jul 15, 2018

Codecov Report

Merging #21924 into master will increase coverage by 0.1%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #21924     +/-   ##
=========================================
+ Coverage   92.04%   92.15%   +0.1%     
=========================================
  Files         169      169             
  Lines       50782    50698     -84     
=========================================
- Hits        46742    46720     -22     
+ Misses       4040     3978     -62
Flag Coverage Δ
#multiple 90.56% <100%> (+0.1%) ⬆️
#single 42.31% <75%> (ø) ⬆️
Impacted Files Coverage Δ
pandas/core/internals/managers.py 96.45% <100%> (-0.03%) ⬇️
pandas/core/generic.py 96.67% <100%> (+0.23%) ⬆️
pandas/plotting/_core.py 83.54% <0%> (+0.05%) ⬆️
pandas/io/parsers.py 95.54% <0%> (+0.06%) ⬆️
pandas/core/indexing.py 93.87% <0%> (+0.08%) ⬆️
pandas/util/testing.py 85.96% <0%> (+0.2%) ⬆️
pandas/core/arrays/datetimes.py 95.74% <0%> (+0.21%) ⬆️
pandas/core/groupby/generic.py 87.04% <0%> (+0.21%) ⬆️
pandas/core/groupby/ops.py 96.79% <0%> (+0.22%) ⬆️
... and 13 more

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 e2e1a10...97ea653. Read the comment docs.

@gfyoung gfyoung added Refactor Internal refactoring of code Internals Related to non-user accessible pandas implementation labels Jul 16, 2018
result._data = result._data.rename_axis(f, axis=baxis, copy=copy,
level=level)

# TODO: we already did a copy above, can we avoid doing again?
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 makes it more confusing here, reaching into internals to do this.

I would rather move _transform_index and items_overlap_with_suffix from internals to Index.base (or appropriate), these are just renaming / transform helpers for an index.

Then this would be much cleaner.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this makes it more confusing here, reaching into internals to do this.

At least add_suffix and add_prefix are clear wins. I can de-_data this a little bit by using NDFrame.set_axis. I'll take a look at transform_index and items_overlap_with_suffix, see if there is a more reasonable place for them.

I would rather [...]

I agree, am working along similar lines.

@jbrockmendel
Copy link
Member Author

@jorisvandenbossche gentle ping; the issue that motivated this PR was yours

@pep8speaks
Copy link

Hello @jbrockmendel! Thanks for updating the PR.

@jbrockmendel
Copy link
Member Author

Updated to get only add_prefix/add_suffix out of internals, leaves rename_axis in internals, so no longer closes #16045.

@jbrockmendel
Copy link
Member Author

@jorisvandenbossche this has been scaled back significantly, but still addresses part of the Issue you opened. Thoughts?

Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

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

No objection to this

@@ -169,27 +169,17 @@ def set_axis(self, axis, new_labels):
def rename_axis(self, mapper, axis, copy=True, level=None):
"""
Rename one of axes.

Parameters
Parameters
Copy link
Member

Choose a reason for hiding this comment

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

can you undo this change?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy/paste snafu, thanks for pointing this out. Will fix shortly.

----------
mapper : unary callable
axis : int
copy : boolean, default True
level : int, default None

"""
"""
Copy link
Member

Choose a reason for hiding this comment

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

this one as well

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

i will have a look soon

@jreback jreback added this to the 0.24.0 milestone Sep 8, 2018
@jreback jreback merged commit 8078500 into pandas-dev:master Sep 8, 2018
@jreback
Copy link
Contributor

jreback commented Sep 8, 2018

thanks!

@jbrockmendel jbrockmendel deleted the rename branch September 8, 2018 03:10
aeltanawy pushed a commit to aeltanawy/pandas that referenced this pull request Sep 20, 2018
Sup3rGeo pushed a commit to Sup3rGeo/pandas that referenced this pull request Oct 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Internals Related to non-user accessible pandas implementation Refactor Internal refactoring of code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CLN: move rename functionality out of internals
5 participants