@@ -546,6 +546,7 @@ def _simple_new(cls, values, name=None, dtype=None, **kwargs):
546
546
def _shallow_copy (self , values = None , ** kwargs ):
547
547
if values is None :
548
548
values = self .values
549
+
549
550
attributes = self ._get_attributes_dict ()
550
551
attributes .update (kwargs )
551
552
if not len (values ) and 'dtype' not in kwargs :
@@ -557,7 +558,6 @@ def _shallow_copy(self, values=None, **kwargs):
557
558
# `self.values` returns `self` for tz-aware, so we need to unwrap
558
559
# more specifically
559
560
values = values .asi8
560
-
561
561
return self ._simple_new (values , ** attributes )
562
562
563
563
def _shallow_copy_with_infer (self , values , ** kwargs ):
@@ -822,6 +822,7 @@ def repeat(self, repeats, *args, **kwargs):
822
822
--------
823
823
Series.repeat : Equivalent function for Series
824
824
numpy.repeat : Underlying implementation
825
+ Series.tile : repeat the entire index as a group, not by element
825
826
826
827
Examples
827
828
--------
@@ -836,6 +837,47 @@ def repeat(self, repeats, *args, **kwargs):
836
837
nv .validate_repeat (args , kwargs )
837
838
return self ._shallow_copy (self ._values .repeat (repeats ))
838
839
840
+ def tile (self , reps , * args , ** kwargs ):
841
+ """
842
+ Tile elements of an Index.
843
+
844
+ Returns a new index constructed by repeating the current index
845
+ the number of times given by reps.
846
+
847
+ .. versionadded:: 0.24.0
848
+
849
+ Parameters
850
+ ----------
851
+ reps : int
852
+ The number of repetitions of the element groups.
853
+ **kwargs
854
+ Additional keywords have no effect but might be accepted for
855
+ compatibility with numpy.
856
+
857
+ Returns
858
+ -------
859
+ pandas.Index
860
+ Newly created Index with tiled elements.
861
+
862
+ See Also
863
+ --------
864
+ Series.tile : Equivalent function for Series
865
+ numpy.tile : Underlying implementation
866
+ Series.repeat : repeat the index element by element, not as a group
867
+
868
+ Examples
869
+ --------
870
+ >>> idx = pd.Index([1, 2, 3])
871
+ >>> idx
872
+ Int64Index([1, 2, 3], dtype='int64')
873
+ >>> idx.tile(2)
874
+ Int64Index([1, 2, 3, 1, 2, 3], dtype='int64')
875
+ >>> idx.tile(3)
876
+ Int64Index([1, 2, 3, 1, 2, 3, 1, 2, 3], dtype='int64')
877
+ """
878
+ nv .validate_tile (args , kwargs )
879
+ return self ._shallow_copy (np .tile (self ._values [:], reps ))
880
+
839
881
_index_shared_docs ['where' ] = """
840
882
.. versionadded:: 0.19.0
841
883
0 commit comments