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

COMPAT-18589: Supporting axis in Series.rename #18923

Merged
merged 5 commits into from
Feb 14, 2018

Conversation

AaronCritchley
Copy link
Contributor

@AaronCritchley AaronCritchley commented Dec 23, 2017

@codecov
Copy link

codecov bot commented Dec 23, 2017

Codecov Report

Merging #18923 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #18923      +/-   ##
==========================================
+ Coverage   91.58%   91.59%   +<.01%     
==========================================
  Files         150      150              
  Lines       48806    48809       +3     
==========================================
+ Hits        44701    44706       +5     
+ Misses       4105     4103       -2
Flag Coverage Δ
#multiple 89.96% <100%> (ø) ⬆️
#single 41.73% <66.66%> (ø) ⬆️
Impacted Files Coverage Δ
pandas/core/generic.py 95.94% <100%> (ø) ⬆️
pandas/util/testing.py 83.85% <0%> (+0.2%) ⬆️

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 569bc7a...1794b98. Read the comment docs.

@@ -862,6 +862,8 @@ def rename(self, *args, **kwargs):
copy = kwargs.pop('copy', True)
inplace = kwargs.pop('inplace', False)
level = kwargs.pop('level', None)
# Axis supported for compatibility, detailed in GH-18589
Copy link
Contributor

Choose a reason for hiding this comment

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

you don't need this comment

def test_axis_supported(self):
# Supporting axis for compatibility, detailed in GH-18589
s = Series(range(5))
s.rename({}, axis=0)
Copy link
Contributor

Choose a reason for hiding this comment

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

test with axis > 0, which will raise

Copy link
Contributor

Choose a reason for hiding this comment

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

move to pandas/tests/series/test_alter_axes.py with other rename tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved tests, can you clarify on the comment about axis > 0 raising?
I added a test but it doesn't raise, we're popping it and never using it - did you mean that it should raise an error? I can implement if that's intended.

Copy link
Contributor

Choose a reason for hiding this comment

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

there should a call of
_getaxis_number
somewhere if not that’s an error

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's no call to that here, as we're not using the argument anywhere.
Would you still like me to add this (and test that the addition is working as intended) despite the argument not being used?

@jreback jreback added the Compat pandas objects compatability with Numpy or Python functions label Dec 23, 2017
@@ -862,6 +862,8 @@ def rename(self, *args, **kwargs):
copy = kwargs.pop('copy', True)
inplace = kwargs.pop('inplace', False)
level = kwargs.pop('level', None)
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 there is an issue about explicity listing the signatures in pandas/core/series and pandas/core/frame, for rename. would take that in this PR as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, happy to do so, just to clarify, you'd like to me to implement them as specific kwargs rather than **kwargs, and default them to None?

Copy link
Contributor

Choose a reason for hiding this comment

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

defaults should be to what they actually default now, these are passed as kwargs to the generic routine, this is mainly to have a nice signature.

# Supporting axis for compatibility, detailed in GH-18589
s = Series(range(5))
s.rename({}, axis=0)
s.rename({}, axis=5)
Copy link
Contributor

Choose a reason for hiding this comment

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

this should raise

@jreback jreback added this to the 0.23.0 milestone Feb 9, 2018
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.

minor change, can you also add a whatsnew note (bug fix in reshaping ok)

@@ -862,6 +862,9 @@ def rename(self, *args, **kwargs):
copy = kwargs.pop('copy', True)
inplace = kwargs.pop('inplace', False)
level = kwargs.pop('level', None)
axis = kwargs.pop('axis', None)
if axis is not None:
self._get_axis_number(axis)
Copy link
Contributor

Choose a reason for hiding this comment

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

axis = self._get_axis_number(axis)

def test_rename_axis_supported(self):
# Supporting axis for compatibility, detailed in GH-18589
s = Series(range(5))
s.rename({}, axis=0)
Copy link
Contributor

Choose a reason for hiding this comment

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

try with axis='index' as welll (should succeed)

Copy link
Contributor

Choose a reason for hiding this comment

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

can you move this after other rename tests?

def test_rename_axis_supported(self):
# Supporting axis for compatibility, detailed in GH-18589
s = Series(range(5))
s.rename({}, axis=0)
Copy link
Contributor

Choose a reason for hiding this comment

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

can you move this after other rename tests?

@jreback jreback merged commit 76f175b into pandas-dev:master Feb 14, 2018
@jreback
Copy link
Contributor

jreback commented Feb 14, 2018

thanks!

@AaronCritchley AaronCritchley deleted the COMPAT-18589-rename-axis branch February 14, 2018 12:05
harisbal pushed a commit to harisbal/pandas that referenced this pull request Feb 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compat pandas objects compatability with Numpy or Python functions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Series.rename doesn't accept "axis" argument
2 participants