pyspark.pandas.Index.insert#
- Index.insert(loc, item)[source]#
- Make new Index inserting new item at location. - Follows Python list.append semantics for negative values. - Changed in version 3.4.0: Raise IndexError when loc is out of bounds to follow Pandas 1.4+ behavior - Parameters
- locint
- itemobject
 
- Returns
- new_indexIndex
 
 - Examples - >>> psidx = ps.Index([1, 2, 3, 4, 5]) >>> psidx.insert(3, 100) Index([1, 2, 3, 100, 4, 5], dtype='int64') - For negative values - >>> psidx = ps.Index([1, 2, 3, 4, 5]) >>> psidx.insert(-3, 100) Index([1, 2, 100, 3, 4, 5], dtype='int64')