29
29
from pandas .compat import set_function_name
30
30
from pandas .compat .numpy import function as nv
31
31
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
37
33
from pandas .util ._validators import (
38
34
validate_bool_kwarg ,
39
35
validate_insert_loc ,
@@ -1627,26 +1623,27 @@ def factorize(
1627
1623
uniques_ea = self ._from_factorized (uniques , self )
1628
1624
return codes , uniques_ea
1629
1625
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.
1632
1629
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
1634
1631
is repeated consecutively a given number of times.
1635
1632
1636
1633
Parameters
1637
1634
----------
1638
1635
repeats : int or array of ints
1639
1636
The number of repetitions for each element. This should be a
1640
1637
non-negative integer. Repeating 0 times will return an empty
1641
- %(klass)s .
1638
+ ExtensionArray .
1642
1639
axis : None
1643
1640
Must be ``None``. Has no effect but is accepted for compatibility
1644
1641
with numpy.
1645
1642
1646
1643
Returns
1647
1644
-------
1648
- %(klass)s
1649
- Newly created %(klass)s with repeated elements.
1645
+ ExtensionArray
1646
+ Newly created ExtensionArray with repeated elements.
1650
1647
1651
1648
See Also
1652
1649
--------
@@ -1657,7 +1654,7 @@ def factorize(
1657
1654
1658
1655
Examples
1659
1656
--------
1660
- >>> cat = pd.Categorical(['a', 'b', 'c' ])
1657
+ >>> cat = pd.Categorical(["a", "b", "c" ])
1661
1658
>>> cat
1662
1659
['a', 'b', 'c']
1663
1660
Categories (3, str): ['a', 'b', 'c']
@@ -1668,10 +1665,6 @@ def factorize(
1668
1665
['a', 'b', 'b', 'c', 'c', 'c']
1669
1666
Categories (3, str): ['a', 'b', 'c']
1670
1667
"""
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 :
1675
1668
nv .validate_repeat ((), {"axis" : axis })
1676
1669
ind = np .arange (len (self )).repeat (repeats )
1677
1670
return self .take (ind )
0 commit comments