|
30 | 30 | from pandas.compat.numpy import function as nv
|
31 | 31 | from pandas.errors import AbstractMethodError
|
32 | 32 | from pandas.util._decorators import (
|
33 |
| - Appender, |
34 |
| - Substitution, |
35 | 33 | cache_readonly,
|
36 | 34 | )
|
37 | 35 | from pandas.util._validators import (
|
@@ -1669,9 +1667,48 @@ def factorize(
|
1669 | 1667 | Categories (3, str): ['a', 'b', 'c']
|
1670 | 1668 | """
|
1671 | 1669 |
|
1672 |
| - @Substitution(klass="ExtensionArray") |
1673 |
| - @Appender(_extension_array_shared_docs["repeat"]) |
1674 | 1670 | def repeat(self, repeats: int | Sequence[int], axis: AxisInt | None = None) -> Self:
|
| 1671 | + """ |
| 1672 | + Repeat elements of an ExtensionArray. |
| 1673 | +
|
| 1674 | + Returns a new ExtensionArray where each element of the current ExtensionArray |
| 1675 | + is repeated consecutively a given number of times. |
| 1676 | +
|
| 1677 | + Parameters |
| 1678 | + ---------- |
| 1679 | + repeats : int or array of ints |
| 1680 | + The number of repetitions for each element. This should be a |
| 1681 | + non-negative integer. Repeating 0 times will return an empty |
| 1682 | + ExtensionArray. |
| 1683 | + axis : None |
| 1684 | + Must be ``None``. Has no effect but is accepted for compatibility |
| 1685 | + with numpy. |
| 1686 | +
|
| 1687 | + Returns |
| 1688 | + ------- |
| 1689 | + ExtensionArray |
| 1690 | + Newly created ExtensionArray with repeated elements. |
| 1691 | +
|
| 1692 | + See Also |
| 1693 | + -------- |
| 1694 | + Series.repeat : Equivalent function for Series. |
| 1695 | + Index.repeat : Equivalent function for Index. |
| 1696 | + numpy.repeat : Similar method for :class:`numpy.ndarray`. |
| 1697 | + ExtensionArray.take : Take arbitrary positions. |
| 1698 | +
|
| 1699 | + Examples |
| 1700 | + -------- |
| 1701 | + >>> cat = pd.Categorical(["a", "b", "c"]) |
| 1702 | + >>> cat |
| 1703 | + ['a', 'b', 'c'] |
| 1704 | + Categories (3, str): ['a', 'b', 'c'] |
| 1705 | + >>> cat.repeat(2) |
| 1706 | + ['a', 'a', 'b', 'b', 'c', 'c'] |
| 1707 | + Categories (3, str): ['a', 'b', 'c'] |
| 1708 | + >>> cat.repeat([1, 2, 3]) |
| 1709 | + ['a', 'b', 'b', 'c', 'c', 'c'] |
| 1710 | + Categories (3, str): ['a', 'b', 'c'] |
| 1711 | + """ |
1675 | 1712 | nv.validate_repeat((), {"axis": axis})
|
1676 | 1713 | ind = np.arange(len(self)).repeat(repeats)
|
1677 | 1714 | return self.take(ind)
|
|
0 commit comments