pandas.eval

pandas 3.1.1 · General functions · function

Evaluate a trusted expression over variables or table columns. A DataFrame call uses its columns as named inputs.

Call syntax

pd.eval(…) Full signature
pd.eval(
    expr,
    parser='pandas',
    engine=None,
    local_dict=None,
    global_dict=None,
    resolvers=(),
    level=0,
    target=None,
    inplace=…,
)

Run the example

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

Parameters

ParameterRequirementAccepted values and behavior
expr Required
Positional or keyword
str

Provide the expression evaluated by pandas.

parser Optional
Positional or keyword
Default 'pandas'
{'pandas', 'python'}
engine Optional
Positional or keyword
Default None
{'python', 'numexpr'}

Choose the implementation that performs the operation.

local_dict Optional
Positional or keyword
Default None
dict or None

Provide local variable bindings available to the expression.

global_dict Optional
Positional or keyword
Default None
dict or None

Provide global variable bindings available to the expression.

resolvers Optional
Positional or keyword
Default ()
list of dict-like or None

Provide objects used to resolve names in an expression.

level Optional
Positional or keyword
Default 0
int

Choose an index level by name or integer position.

target Optional
Positional or keyword
Default None
object

Supply the labels to align or match against.

inplace Optional
Positional or keyword
bool

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

Returns

ndarray, numeric scalar, DataFrame, Series, or None