pandas.DataFrame.dropna

pandas 3.1.1 · DataFrame · method

Drop entries with missing values. For DataFrames, subset restricts the columns considered when dropping rows.

Call syntax

DataFrame.dropna(*, axis=0, how=…, thresh=…, subset=None, inplace=…, ignore_index=False)

Run the example

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

Parameters

ParameterRequirementAccepted values and behavior
axis Optional
Keyword only
Default 0
{0 or 'index', 1 or 'columns'}

Use 0 or "index" to remove rows. Use 1 or "columns" to remove columns.

how Optional
Keyword only
{'any', 'all'}

Choose "any" to drop an entry with at least one missing value, or "all" to drop it only when all checked values are missing.

thresh Optional
Keyword only
int

Keep only entries with at least this many nonmissing values. Supply thresh by itself instead of combining it with how.

subset Optional
Keyword only
Default None
column label or iterable of labels

Limit the check to the given labels on the other axis, such as ["units"] when dropping rows.

inplace Optional
Keyword only
bool

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

ignore_index Optional
Keyword only
Default False
bool

Give the resulting axis new integer labels where supported.

Returns

A DataFrame with the selected rows or columns removed. When inplace=True, returns None and updates the original.