Skip to content

Commit 06e3321

Browse files
jschendelPingviinituutti
authored andcommitted
API: Simplify repeat signature (pandas-dev#24447)
1 parent 7d7bc7b commit 06e3321

File tree

7 files changed

+23
-32
lines changed

7 files changed

+23
-32
lines changed

pandas/core/arrays/base.py

+5-8
Original file line numberDiff line numberDiff line change
@@ -605,12 +605,9 @@ def factorize(self, na_sentinel=-1):
605605
The number of repetitions for each element. This should be a
606606
non-negative integer. Repeating 0 times will return an empty
607607
%(klass)s.
608-
*args
609-
Additional arguments have no effect but might be accepted for
610-
compatibility with numpy.
611-
**kwargs
612-
Additional keywords have no effect but might be accepted for
613-
compatibility with numpy.
608+
axis : None
609+
Must be ``None``. Has no effect but is accepted for compatibility
610+
with numpy.
614611
615612
Returns
616613
-------
@@ -640,8 +637,8 @@ def factorize(self, na_sentinel=-1):
640637

641638
@Substitution(klass='ExtensionArray')
642639
@Appender(_extension_array_shared_docs['repeat'])
643-
def repeat(self, repeats, *args, **kwargs):
644-
nv.validate_repeat(args, kwargs)
640+
def repeat(self, repeats, axis=None):
641+
nv.validate_repeat(tuple(), dict(axis=axis))
645642
ind = np.arange(len(self)).repeat(repeats)
646643
return self.take(ind)
647644

pandas/core/arrays/categorical.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2402,8 +2402,8 @@ def describe(self):
24022402

24032403
@Substitution(klass='Categorical')
24042404
@Appender(_extension_array_shared_docs['repeat'])
2405-
def repeat(self, repeats, *args, **kwargs):
2406-
nv.validate_repeat(args, kwargs)
2405+
def repeat(self, repeats, axis=None):
2406+
nv.validate_repeat(tuple(), dict(axis=axis))
24072407
codes = self._codes.repeat(repeats)
24082408
return self._constructor(values=codes, dtype=self.dtype, fastpath=True)
24092409

pandas/core/arrays/interval.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1002,8 +1002,8 @@ def to_tuples(self, na_tuple=True):
10021002
return tuples
10031003

10041004
@Appender(_extension_array_shared_docs['repeat'] % _shared_docs_kwargs)
1005-
def repeat(self, repeats, *args, **kwargs):
1006-
nv.validate_repeat(args, kwargs)
1005+
def repeat(self, repeats, axis=None):
1006+
nv.validate_repeat(tuple(), dict(axis=axis))
10071007
left_repeat = self.left.repeat(repeats)
10081008
right_repeat = self.right.repeat(repeats)
10091009
return self._shallow_copy(left=left_repeat, right=right_repeat)

pandas/core/indexes/base.py

+5-8
Original file line numberDiff line numberDiff line change
@@ -846,12 +846,9 @@ def _assert_take_fillable(self, values, indices, allow_fill=True,
846846
The number of repetitions for each element. This should be a
847847
non-negative integer. Repeating 0 times will return an empty
848848
%(klass)s.
849-
*args
850-
Additional arguments have no effect but might be accepted for
851-
compatibility with numpy.
852-
**kwargs
853-
Additional keywords have no effect but might be accepted for
854-
compatibility with numpy.
849+
axis : None
850+
Must be ``None``. Has no effect but is accepted for compatibility
851+
with numpy.
855852
856853
Returns
857854
-------
@@ -875,8 +872,8 @@ def _assert_take_fillable(self, values, indices, allow_fill=True,
875872
"""
876873

877874
@Appender(_index_shared_docs['repeat'] % _index_doc_kwargs)
878-
def repeat(self, repeats, *args, **kwargs):
879-
nv.validate_repeat(args, kwargs)
875+
def repeat(self, repeats, axis=None):
876+
nv.validate_repeat(tuple(), dict(axis=axis))
880877
return self._shallow_copy(self._values.repeat(repeats))
881878

882879
# --------------------------------------------------------------------

pandas/core/indexes/datetimelike.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -451,8 +451,8 @@ def isin(self, values):
451451
return algorithms.isin(self.asi8, values.asi8)
452452

453453
@Appender(_index_shared_docs['repeat'] % _index_doc_kwargs)
454-
def repeat(self, repeats, *args, **kwargs):
455-
nv.validate_repeat(args, kwargs)
454+
def repeat(self, repeats, axis=None):
455+
nv.validate_repeat(tuple(), dict(axis=axis))
456456
freq = self.freq if is_period_dtype(self) else None
457457
return self._shallow_copy(self.asi8.repeat(repeats), freq=freq)
458458

pandas/core/indexes/multi.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1858,8 +1858,8 @@ def argsort(self, *args, **kwargs):
18581858
return self.values.argsort(*args, **kwargs)
18591859

18601860
@Appender(_index_shared_docs['repeat'] % _index_doc_kwargs)
1861-
def repeat(self, repeats, *args, **kwargs):
1862-
nv.validate_repeat(args, kwargs)
1861+
def repeat(self, repeats, axis=None):
1862+
nv.validate_repeat(tuple(), dict(axis=axis))
18631863
return MultiIndex(levels=self.levels,
18641864
codes=[level_codes.view(np.ndarray).repeat(repeats)
18651865
for level_codes in self.codes],

pandas/core/series.py

+5-8
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,7 @@ def _set_values(self, key, value):
10371037
self._data = self._data.setitem(indexer=key, value=value)
10381038
self._maybe_update_cacher()
10391039

1040-
def repeat(self, repeats, *args, **kwargs):
1040+
def repeat(self, repeats, axis=None):
10411041
"""
10421042
Repeat elements of a Series.
10431043
@@ -1050,12 +1050,9 @@ def repeat(self, repeats, *args, **kwargs):
10501050
The number of repetitions for each element. This should be a
10511051
non-negative integer. Repeating 0 times will return an empty
10521052
Series.
1053-
*args
1054-
Additional arguments have no effect but might be accepted for
1055-
compatibility with numpy.
1056-
**kwargs
1057-
Additional keywords have no effect but might be accepted for
1058-
compatibility with numpy.
1053+
axis : None
1054+
Must be ``None``. Has no effect but is accepted for compatibility
1055+
with numpy.
10591056
10601057
Returns
10611058
-------
@@ -1092,7 +1089,7 @@ def repeat(self, repeats, *args, **kwargs):
10921089
2 c
10931090
dtype: object
10941091
"""
1095-
nv.validate_repeat(args, kwargs)
1092+
nv.validate_repeat(tuple(), dict(axis=axis))
10961093
new_index = self.index.repeat(repeats)
10971094
new_values = self._values.repeat(repeats)
10981095
return self._constructor(new_values,

0 commit comments

Comments
 (0)