8000 ENH: Allow rename_axis to specify index and columns arguments by Dr-Irv · Pull Request #20046 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

ENH: Allow rename_axis to specify index and columns arguments #20046

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 19 commits into from
Oct 29, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
stacklevel for warnings
  • Loading branch information
Dr-Irv committed Oct 26, 2018
commit e965c5b603595a8454933e479e7ce74445b2c6e2
2 changes: 1 addition & 1 deletion pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1255,7 +1255,7 @@ def 8000 rename_axis(self, mapper=None, **kwargs):
# and not a list or scalar, then call rename
msg = ("Using 'rename_axis' to alter labels is deprecated. "
"Use '.rename' instead")
warnings.warn(msg, FutureWarning, stacklevel=2)
warnings.warn(msg, FutureWarning, stacklevel=3)
axis = self._get_axis_name(axis)
d = {'copy': copy, 'inplace': inplace}
d[axis] = mapper
Expand Down
12 changes: 4 additions & 8 deletions pandas/tests/frame/test_alter_axes.py
5C97
Original file line number Diff line number Diff line change
Expand Up @@ -522,23 +522,19 @@ def test_rename_axis_inplace(self, float_frame):
def test_rename_axis_warns(self):
# https://github.com/pandas-dev/pandas/issues/17833
df = DataFrame({"A": [1, 2], "B": [1, 2]})
with tm.assert_produces_warning(FutureWarning,
check_stacklevel=False) as w:
with tm.assert_produces_warning(FutureWarning) as w:
df.rename_axis(id, axis=0)
assert 'rename' in str(w[0].message)

with tm.assert_produces_warning(FutureWarning,
check_stacklevel=False) as w:
with tm.assert_produces_warning(FutureWarning) as w:
df.rename_axis({0: 10, 1: 20}, axis=0)
assert 'rename' in str(w[0].message)

with tm.assert_produces_warning(FutureWarning,
check_stacklevel=False) as w:
with tm.assert_produces_warning(FutureWarning) as w:
df.rename_axis(id, axis=1)
assert 'rename' in str(w[0].message)

with tm.assert_produces_warning(FutureWarning,
check_stacklevel=False) as w:
with tm.assert_produces_warning(FutureWarning) as w:
df['A'].rename_axis(id)
assert 'rename' in str(w[0].message)

Expand Down
0