使用repeat()函數(shù)重復pandas Series:
s = pd.Series(['a', 'b', 'c'])
s.repeat(2)
0 a
0 a
1 b
1 b
2 c
2 c
dtype: object
需要得到如下輸出:
0 a
1 b
2 c
0 a
1 b
2 c
dtype: object
使用repeat()函數(shù)重復pandas Series:
s = pd.Series(['a', 'b', 'c'])
s.repeat(2)
0 a
0 a
1 b
1 b
2 c
2 c
dtype: object
需要得到如下輸出:
0 a
1 b
2 c
0 a
1 b
2 c
dtype: object
公眾號:1024技術(shù)圈
?? 提供互聯(lián)網(wǎng)知識和資訊,分享IT前沿技術(shù),熱門資源,大廠面試題 ??
如果性能很重要,請將
np.tile
與Series.loc
一起使用:EDIT: