From d96a334c4370a15700aa73c7348646c50afa3539 Mon Sep 17 00:00:00 2001 From: gfyoung Date: Tue, 4 Sep 2018 04:13:34 -0700 Subject: [PATCH] CLN: Rename 'n' to 'repeats' in .repeat methods (#22574) For Index and MultiIndex. xref gh-14645. --- doc/source/whatsnew/v0.24.0.txt | 1 + pandas/core/indexes/base.py | 3 +-- pandas/core/indexes/multi.py | 3 +-- pandas/tests/indexes/multi/test_reshape.py | 4 ---- pandas/tests/indexes/test_base.py | 9 --------- 5 files changed, 3 insertions(+), 17 deletions(-) diff --git a/doc/source/whatsnew/v0.24.0.txt b/doc/source/whatsnew/v0.24.0.txt index 2bfc57d7f5dcd..3a360b09ae789 100644 --- a/doc/source/whatsnew/v0.24.0.txt +++ b/doc/source/whatsnew/v0.24.0.txt @@ -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: diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 7b7fb968b3050..710c9d0e296c9 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -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 @@ -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. diff --git a/pandas/core/indexes/multi.py b/pandas/core/indexes/multi.py index 5b2e3a76adf05..955f1461075f9 100644 --- a/pandas/core/indexes/multi.py +++ b/pandas/core/indexes/multi.py @@ -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 @@ -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, diff --git a/pandas/tests/indexes/multi/test_reshape.py b/pandas/tests/indexes/multi/test_reshape.py index efa9fca752157..7750379bff445 100644 --- a/pandas/tests/indexes/multi/test_reshape.py +++ b/pandas/tests/indexes/multi/test_reshape.py @@ -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): diff --git a/pandas/tests/indexes/test_base.py b/pandas/tests/indexes/test_base.py index c858b4d86cf5e..755b3cc7f1dca 100644 --- a/pandas/tests/indexes/test_base.py +++ b/pandas/tests/indexes/test_base.py @@ -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]),