用法:
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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。