Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

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.

Syntax:

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

Parameters:

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
Required
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
Required
errors If ‘ignore’, suppress error and only existing labels are dropped. {‘ignore’, ‘raise’}
Default Value: ‘raise’
Required

Returns: Series
Series with specified index labels removed.

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

Example:


Download the Pandas Series Notebooks from here.

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