pandas.Index.insert#
- Index.insert(loc, item)[源代码][源代码]#
在指定位置插入新项目创建新索引。
遵循 Python numpy.insert 对负值的语义。
- 参数:
- locint
新项目将被插入的整数位置。
- 项目对象
要插入索引的新项目。
- 返回:
- 索引
返回一个新的索引对象,该对象是通过将指定项插入到原始索引中的指定位置而得到的。
参见
Index.append
将一系列索引集合在一起。
示例
>>> idx = pd.Index(["a", "b", "c"]) >>> idx.insert(1, "x") Index(['a', 'x', 'b', 'c'], dtype='object')