pandas.DataFrame.drop

pandas 3.1.1 · DataFrame · method

Remove rows or columns by label. Specify columns= to make column removal explicit.

Call syntax

DataFrame.drop(…) Full signature
DataFrame.drop(
    labels=None,
    *,
    axis=0,
    index=None,
    columns=None,
    level=None,
    inplace=…,
    errors='raise',
)

Run the example

Edit the example and select Run Python to see the result.

Parameters

ParameterRequirementAccepted values and behavior
labels Optional
Positional or keyword
Default None
single label or iterable of labels

Provide the labels used for selecting rows, renaming entries, or naming bins.

axis Optional
Keyword only
Default 0
{0 or 'index', 1 or 'columns'}

Choose which axis the operation acts on. The accepted axis labels depend on the receiver.

index Optional
Keyword only
Default None
single label or iterable of labels

Supply row labels or control how existing row labels are used.

columns Optional
Keyword only
Default None
single label or iterable of labels

Supply column labels or control how columns are handled.

level Optional
Keyword only
Default None
int or level name

Choose an index level by name or integer position.

inplace Optional
Keyword only
bool

Choose whether to change the existing object. Where supported, an in-place call typically returns None.

errors Optional
Keyword only
Default 'raise'
{'ignore', 'raise'}

Choose how to handle invalid input or failed operations. The available options depend on the API.

Returns

DataFrame or None