Skip to content

Commit

Permalink
CLN: Rename 'n' to 'repeats' in .repeat methods
Browse files Browse the repository at this point in the history
For Index and MultiIndex.

xref gh-14645.
  • Loading branch information
gfyoung committed Sep 2, 2018
1 parent 550a5ca commit 780019d
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 17 deletions.
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`)
-

.. _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

0 comments on commit 780019d

Please sign in to comment.