Python | Pandas Index.repeat() Last Updated : 18 Dec, 2018 Summarize Comments Improve Suggest changes Share Like Article Like Report Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas Index.repeat() function repeat elements of an Index. The function returns a new index where each element of the current index is repeated consecutively a given number of times. Syntax: Index.repeat(repeats, *args, **kwargs) Parameters : repeats : The number of repetitions for each element. **kwargs : Additional keywords have no effect but might be accepted for compatibility with numpy. Returns : Newly created Index with repeated elements. Example #1: Use Index.repeat()() function to repeat the elements of the index 2 times. Python3 # importing pandas as pd import pandas as pd # Creating the index idx = pd.Index(['Beagle', 'Pug', 'Labrador', 'Pug', 'Mastiff', None, 'Beagle']) # Print the Index idx Output : Let's repeat the index elements 2 times. Python3 # to repeat the values idx.repeat(2) Output : As we can see in the output, the function has returned a new index with all the values repeated 2 times. One important thing to notice is that the function has also repeated the NaN value. Example #2: Use Index.repeat() function to repeat the value of index 3 times. Python3 # importing pandas as pd import pandas as pd # Creating the index idx = pd.Index([22, 14, 8, 56, None, 21, None, 23]) # Print the Index idx Output : Let's repeat the index elements 3 times. Python3 # to repeat the values idx.repeat(3) Output : As we can see in the output, the function has returned a new index with all the values repeated 3 times. One important thing to notice is that the function has also repeated the NaN value. Comment More infoAdvertise with us Next Article Python | Pandas Index.to_series() S Shubham__Ranjan Follow Improve Article Tags : Technical Scripter Python Python-pandas Python pandas-indexing Practice Tags : python Similar Reads Python | Pandas Index.shape Pandas Index is an immutable ndarray implementing an ordered, sliceable set. It is the basic object which stores the axis labels for all pandas objects. Pandas Index.shape attribute return a tuple of the shape of the underlying data in the given Index object. Syntax: Index.shape Parameter : None Ret 2 min read Python | Pandas Index.where Pandas Index is an immutable ndarray implementing an ordered, sliceable set. It is the basic object which stores the axis labels for all pandas objects. Pandas Index.where function return an Index of same shape as self and whose corresponding entries are from self where cond is True and otherwise ar 2 min read Python | Pandas Index.to_series() Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas Index.to_series() function create a Series with both index and values equal to 2 min read Python | Pandas Index.size Pandas Index is an immutable ndarray implementing an ordered, sliceable set. It is the basic object which stores the axis labels for all pandas objects. Pandas Index.size attribute return the number of elements in the underlying data of the given Index object. Syntax: Index.size Parameter : None Ret 2 min read Python | Pandas Series.reset_index() Pandas series is a One-dimensional ndarray with axis labels. The labels need not be unique but must be a hashable type. The object supports both integer- and label-based indexing and provides a host of methods for performing operations involving the index. Pandas Series.reset_index() function genera 2 min read Python | Pandas Series.str.index() Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric Python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas str.index() method is used to search and return lowest index of a substring in 3 min read Like