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

CLN: Rename 'n' to 'repeats' in .repeat methods #22574

Merged
merged 1 commit into from
Sep 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.24.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ Removal of prior version deprecations/changes
- Several private functions were removed from the (non-public) module ``pandas.core.common`` (:issue:`22001`)
- Removal of the previously deprecated module ``pandas.core.datetools`` (:issue:`14105`, :issue:`14094`)
- Strings passed into :meth:`DataFrame.groupby` that refer to both column and index levels will raise a ``ValueError`` (:issue:`14432`)
- :meth:`Index.repeat` and :meth:`MultiIndex.repeat` have renamed the ``n`` argument to ``repeats``(:issue:`14645`)
-
Copy link
Contributor

Choose a reason for hiding this comment

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

n is being removed though, not renamed? Maybe

:meth:Index.repeat and :meth:MultiIndex.repeat have the n synonym to the repeats argument removed (deprecated since v.0.20.0) ). (:issue:14645)

Copy link
Member Author

Choose a reason for hiding this comment

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

The original argument was n. Then we deprecated in favor of repeats. Now we're permanently renaming it to repeats. That's why it's described as such.

Copy link
Contributor

Choose a reason for hiding this comment

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

The way I see it is that in 0.20 n was renamed and deprecated, and now the deprecated param n is being removed...

Anyway, could just be a difference of perspective.

Copy link
Member Author

Choose a reason for hiding this comment

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

Anyway, could just be a difference of perspective.

Agreed.


.. _whatsnew_0240.performance:
Expand Down
3 changes: 1 addition & 2 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
import pandas.core.common as com
from pandas.core import ops
from pandas.util._decorators import (
Appender, Substitution, cache_readonly, deprecate_kwarg)
Appender, Substitution, cache_readonly)
from pandas.core.indexes.frozen import FrozenList
import pandas.core.dtypes.concat as _concat
import pandas.core.missing as missing
Expand Down Expand Up @@ -773,7 +773,6 @@ def memory_usage(self, deep=False):
return result

# ops compat
@deprecate_kwarg(old_arg_name='n', new_arg_name='repeats')
def repeat(self, repeats, *args, **kwargs):
"""
Repeat elements of an Index.
Expand Down
3 changes: 1 addition & 2 deletions pandas/core/indexes/multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from pandas.core.dtypes.missing import isna, array_equivalent
from pandas.errors import PerformanceWarning, UnsortedIndexError

from pandas.util._decorators import Appender, cache_readonly, deprecate_kwarg
from pandas.util._decorators import Appender, cache_readonly
import pandas.core.common as com
import pandas.core.missing as missing
import pandas.core.algorithms as algos
Expand Down Expand Up @@ -1646,7 +1646,6 @@ def append(self, other):
def argsort(self, *args, **kwargs):
return self.values.argsort(*args, **kwargs)

@deprecate_kwarg(old_arg_name='n', new_arg_name='repeats')
def repeat(self, repeats, *args, **kwargs):
nv.validate_repeat(args, kwargs)
return MultiIndex(levels=self.levels,
Expand Down
4 changes: 0 additions & 4 deletions pandas/tests/indexes/multi/test_reshape.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,6 @@ def test_repeat():
numbers, names.repeat(reps)], names=names)
tm.assert_index_equal(m.repeat(reps), expected)

with tm.assert_produces_warning(FutureWarning):
result = m.repeat(n=reps)
tm.assert_index_equal(result, expected)


def test_insert_base(idx):

Expand Down
9 changes: 0 additions & 9 deletions pandas/tests/indexes/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2402,15 +2402,6 @@ def test_repeat(self):
result = index.repeat(repeats)
tm.assert_index_equal(result, expected)

def test_repeat_warns_n_keyword(self):
index = pd.Index([1, 2, 3])
expected = pd.Index([1, 1, 2, 2, 3, 3])

with tm.assert_produces_warning(FutureWarning):
result = index.repeat(n=2)

tm.assert_index_equal(result, expected)

@pytest.mark.parametrize("index", [
pd.Index([np.nan]), pd.Index([np.nan, 1]),
pd.Index([1, 2, np.nan]), pd.Index(['a', 'b', np.nan]),
Expand Down