Pandas Series: drop() function

Remove series with specified index labels

The drop() function is used to get series with specified index labels removed.

Remove elements of a Series based on specifying the index labels. When using a multi-index, labels on different levels can be removed by specifying the level.


Series.drop(self, labels=None, axis=0, index=None, columns=None, level=None, inplace=False, errors='raise')
Pandas Series drop image


Name Description Type/Default Value Required / Optional
labels Index labels to drop. single label or list-like Required
axis Redundant for application on Series. 0
Default Value: 0
index, columns Redundant for application on Series, but index can be used instead of labels. Default Value: None Required
level For MultiIndex, level for which the labels will be removed. int or level name optional
inplace If True, do operation inplace and return None. bool
Default Value: False
errors If ‘ignore’, suppress error and only existing labels are dropped. {‘ignore’, ‘raise’}
Default Value: ‘raise’

Returns: Series
Series with specified index labels removed.

Raises: KeyError
If none of the labels are found in the index.


Download the above Notebook from here.

Previous: Series containing counts of unique values in Pandas
Next: Series-droplevel() function