Index.delete() returns a new object with passed locations removed. We can pass more than one place to delete as a list.
Syntax: Index.delete (loc)
loc: Scalar / List of Indices
Returns: new_index: Index
Example # 1: Use
Index.delete () to delete the first value in the index.
Let’s delete the month" January ". It’s at index 0, so we’ll pass 0 as an argument to the function.
As we can see in the output, the function returned an object with the first label removed.
Example # 2: Use
Index.delete () to delete more than one shortcut in an index.
Let’s remove the second, third, fourth and fifth indexes from the index. We pass the list of values to remove to the function.
How we can see that the labels corresponding to the passed values in the index have been removed.