Skip to content

Commit 17f18f2

Browse files
committed
CLN: Rename 'n' to 'repeats' in .repeat methods
For Index and MultiIndex. xref pandas-devgh-14645.
1 parent 550a5ca commit 17f18f2

File tree

5 files changed

+1
-15
lines changed

5 files changed

+1
-15
lines changed

doc/source/whatsnew/v0.24.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,7 @@ Removal of prior version deprecations/changes
527527
- Several private functions were removed from the (non-public) module ``pandas.core.common`` (:issue:`22001`)
528528
- Removal of the previously deprecated module ``pandas.core.datetools`` (:issue:`14105`, :issue:`14094`)
529529
- Strings passed into :meth:`DataFrame.groupby` that refer to both column and index levels will raise a ``ValueError`` (:issue:`14432`)
530+
- :meth:`Index.repeat` and :meth:`MultiIndex.repeat` have renamed the ``n`` argument to ``repeats``(:issue:`14645`)
530531
-
531532

532533
.. _whatsnew_0240.performance:

pandas/core/indexes/base.py

-1
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,6 @@ def memory_usage(self, deep=False):
773773
return result
774774

775775
# ops compat
776-
@deprecate_kwarg(old_arg_name='n', new_arg_name='repeats')
777776
def repeat(self, repeats, *args, **kwargs):
778777
"""
779778
Repeat elements of an Index.

pandas/core/indexes/multi.py

-1
Original file line numberDiff line numberDiff line change
@@ -1646,7 +1646,6 @@ def append(self, other):
16461646
def argsort(self, *args, **kwargs):
16471647
return self.values.argsort(*args, **kwargs)
16481648

1649-
@deprecate_kwarg(old_arg_name='n', new_arg_name='repeats')
16501649
def repeat(self, repeats, *args, **kwargs):
16511650
nv.validate_repeat(args, kwargs)
16521651
return MultiIndex(levels=self.levels,

pandas/tests/indexes/multi/test_reshape.py

-4
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,6 @@ def test_repeat():
100100
numbers, names.repeat(reps)], names=names)
101101
tm.assert_index_equal(m.repeat(reps), expected)
102102

103-
with tm.assert_produces_warning(FutureWarning):
104-
result = m.repeat(n=reps)
105-
tm.assert_index_equal(result, expected)
106-
107103

108104
def test_insert_base(idx):
109105

pandas/tests/indexes/test_base.py

-9
Original file line numberDiff line numberDiff line change
@@ -2402,15 +2402,6 @@ def test_repeat(self):
24022402
result = index.repeat(repeats)
24032403
tm.assert_index_equal(result, expected)
24042404

2405-
def test_repeat_warns_n_keyword(self):
2406-
index = pd.Index([1, 2, 3])
2407-
expected = pd.Index([1, 1, 2, 2, 3, 3])
2408-
2409-
with tm.assert_produces_warning(FutureWarning):
2410-
result = index.repeat(n=2)
2411-
2412-
tm.assert_index_equal(result, expected)
2413-
24142405
@pytest.mark.parametrize("index", [
24152406
pd.Index([np.nan]), pd.Index([np.nan, 1]),
24162407
pd.Index([1, 2, np.nan]), pd.Index(['a', 'b', np.nan]),

0 commit comments

Comments
 (0)