pandas.DataFrame.filter

pandas 3.1.1 · DataFrame · method

Select by labels on a DataFrame or Series. On GroupBy keep groups passing a boolean callable.

Call syntax

DataFrame.filter(arg=None, /, like=None, regex=None, axis=None, *, items=None, cond=None, na=False)

Run the example

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

Parameters

ParameterRequirementAccepted values and behavior
arg Optional
Positional only
Default None
callable, expression, or list-like
like Optional
Positional or keyword
Default None
str
regex Optional
Positional or keyword
Default None
str (regular expression)

Choose whether a supplied pattern is interpreted as a regular expression.

axis Optional
Positional or keyword
Default None
{0 or 'index', 1 or 'columns', None}

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

items Optional
Keyword only
Default None
list-like
cond Optional
Keyword only
Default None
array-like of bool, callable, or expression

Provide a condition or callable producing a boolean mask.

na Optional
Keyword only
Default False
{"raise", True, False}

Supply the value to use for records whose input is missing.

Returns

Same type as caller