Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
Ctrl+K

pandas.Series.repeat#

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

Repeat elements of a Series.

Returns a new Series where each element of the current Seriesis 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 emptySeries.

axisNone

Unused. Parameter needed for compatibility with DataFrame.

Returns:
Series

Newly created Series with repeated elements.

See also

Index.repeat

Equivalent function for Index.

numpy.repeat

Similar method fornumpy.ndarray.

Examples

>>>s=pd.Series(['a','b','c'])>>>s0    a1    b2    cdtype: object>>>s.repeat(2)0    a0    a1    b1    b2    c2    cdtype: object>>>s.repeat([1,2,3])0    a1    b1    b2    c2    c2    cdtype: object

[8]ページ先頭

©2009-2025 Movatter.jp