Skip to content

Commit 67c24ad

Browse files
committed
DOC: inline docstring for ExtensionArray.repeat; remove Substitution/Appender
1 parent e97a56e commit 67c24ad

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

pandas/core/arrays/base.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,7 @@
2929
from pandas.compat import set_function_name
3030
from pandas.compat.numpy import function as nv
3131
from pandas.errors import AbstractMethodError
32-
from pandas.util._decorators import (
33-
Appender,
34-
Substitution,
35-
cache_readonly,
36-
)
32+
from pandas.util._decorators import cache_readonly
3733
from pandas.util._validators import (
3834
validate_bool_kwarg,
3935
validate_insert_loc,
@@ -1627,26 +1623,27 @@ def factorize(
16271623
uniques_ea = self._from_factorized(uniques, self)
16281624
return codes, uniques_ea
16291625

1630-
_extension_array_shared_docs["repeat"] = """
1631-
Repeat elements of a %(klass)s.
1626+
def repeat(self, repeats: int | Sequence[int], axis: AxisInt | None = None) -> Self:
1627+
"""
1628+
Repeat elements of an ExtensionArray.
16321629
1633-
Returns a new %(klass)s where each element of the current %(klass)s
1630+
Returns a new ExtensionArray where each element of the current ExtensionArray
16341631
is repeated consecutively a given number of times.
16351632
16361633
Parameters
16371634
----------
16381635
repeats : int or array of ints
16391636
The number of repetitions for each element. This should be a
16401637
non-negative integer. Repeating 0 times will return an empty
1641-
%(klass)s.
1638+
ExtensionArray.
16421639
axis : None
16431640
Must be ``None``. Has no effect but is accepted for compatibility
16441641
with numpy.
16451642
16461643
Returns
16471644
-------
1648-
%(klass)s
1649-
Newly created %(klass)s with repeated elements.
1645+
ExtensionArray
1646+
Newly created ExtensionArray with repeated elements.
16501647
16511648
See Also
16521649
--------
@@ -1657,7 +1654,7 @@ def factorize(
16571654
16581655
Examples
16591656
--------
1660-
>>> cat = pd.Categorical(['a', 'b', 'c'])
1657+
>>> cat = pd.Categorical(["a", "b", "c"])
16611658
>>> cat
16621659
['a', 'b', 'c']
16631660
Categories (3, str): ['a', 'b', 'c']
@@ -1668,10 +1665,6 @@ def factorize(
16681665
['a', 'b', 'b', 'c', 'c', 'c']
16691666
Categories (3, str): ['a', 'b', 'c']
16701667
"""
1671-
1672-
@Substitution(klass="ExtensionArray")
1673-
@Appender(_extension_array_shared_docs["repeat"])
1674-
def repeat(self, repeats: int | Sequence[int], axis: AxisInt | None = None) -> Self:
16751668
nv.validate_repeat((), {"axis": axis})
16761669
ind = np.arange(len(self)).repeat(repeats)
16771670
return self.take(ind)

0 commit comments

Comments
 (0)