Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
Ctrl+K

pandas.Index.repeat#

Index.repeat(repeats,axis=None)[source]#

Repeat elements of a Index.

Returns a new Index where each element of the current Indexis repeated consecutively a given number of times.

Parameters:
repeatsint or array of ints

The number of repetitions for each element. This should be anon-negative integer. Repeating 0 times will return an emptyIndex.

axisNone

Must beNone. Has no effect but is accepted for compatibilitywith numpy.

Returns:
Index

Newly created Index with repeated elements.

See also

Series.repeat

Equivalent function for Series.

numpy.repeat

Similar method fornumpy.ndarray.

Examples

>>>idx=pd.Index(['a','b','c'])>>>idxIndex(['a', 'b', 'c'], dtype='object')>>>idx.repeat(2)Index(['a', 'a', 'b', 'b', 'c', 'c'], dtype='object')>>>idx.repeat([1,2,3])Index(['a', 'b', 'b', 'c', 'c', 'c'], dtype='object')

[8]ページ先頭

©2009-2025 Movatter.jp