用法:
Index.repeat(repeats, axis=None)
重複索引的元素。
返回一個新索引,其中當前索引的每個元素連續重複給定次數。
- repeats:整數或整數數組
每個元素的重複次數。這應該是一個非負整數。重複 0 次將返回一個空索引。
- axis:None
必須是
None
。沒有效果,但被接受以與 numpy 兼容。
- repeated_index: index
新創建的具有重複元素的索引。
參數:
返回:
例子:
>>> idx = pd.Index(['a', 'b', 'c']) >>> idx Index(['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')
相關用法
- Python pandas.Index.reindex用法及代碼示例
- Python pandas.Index.rename用法及代碼示例
- Python pandas.Index.value_counts用法及代碼示例
- Python pandas.Index.argmin用法及代碼示例
- Python pandas.Index.is_categorical用法及代碼示例
- Python pandas.Index.to_series用法及代碼示例
- Python pandas.Index.str用法及代碼示例
- Python pandas.Index.to_numpy用法及代碼示例
- Python pandas.Index.is_object用法及代碼示例
- Python pandas.Index.slice_indexer用法及代碼示例
- Python pandas.Index.is_interval用法及代碼示例
- Python pandas.Index.notnull用法及代碼示例
- Python pandas.Index.equals用法及代碼示例
- Python pandas.Index.set_names用法及代碼示例
- Python pandas.Index.searchsorted用法及代碼示例
- Python pandas.Index.duplicated用法及代碼示例
- Python pandas.Index.is_monotonic_increasing用法及代碼示例
- Python pandas.Index.min用法及代碼示例
- Python pandas.Index.is_monotonic_decreasing用法及代碼示例
- Python pandas.Index.max用法及代碼示例
注:本文由純淨天空篩選整理自pandas.pydata.org大神的英文原創作品 pandas.Index.repeat。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。