pyspark.pandas.MultiIndex.delete

MultiIndex.delete(loc: Union[int, List[int]]) → pyspark.pandas.indexes.base.Index

Make new Index with passed location(-s) deleted.

Note

this API can be pretty expensive since it is based on a global sequence internally.

Returns
new_indexIndex

Examples

>>> psidx = ps.Index([10, 10, 9, 8, 4, 2, 4, 4, 2, 2, 10, 10])
>>> psidx
Int64Index([10, 10, 9, 8, 4, 2, 4, 4, 2, 2, 10, 10], dtype='int64')
>>> psidx.delete(0).sort_values()
Int64Index([2, 2, 2, 4, 4, 4, 8, 9, 10, 10, 10], dtype='int64')
>>> psidx.delete([0, 1, 2, 3, 10, 11]).sort_values()
Int64Index([2, 2, 2, 4, 4, 4], dtype='int64')

MultiIndex

>>> psidx = ps.MultiIndex.from_tuples([('a', 'x', 1), ('b', 'y', 2), ('c', 'z', 3)])
>>> psidx  
MultiIndex([('a', 'x', 1),
            ('b', 'y', 2),
            ('c', 'z', 3)],
           )
>>> psidx.delete([0, 2]).sort_values()  
MultiIndex([('b', 'y', 2)],
           )