pandas.errors.UndefinedVariableError — pandas 3.0.0.dev0+2105.g29e01463a6 documentation (original) (raw)
exception pandas.errors.UndefinedVariableError(name, is_local=None)[source]#
Exception raised by query
or eval
when using an undefined variable name.
It will also specify whether the undefined variable is local or not.
Parameters:
namestr
The name of the undefined variable.
is_localbool or None, optional
Indicates whether the undefined variable is considered a local variable. If True
, the error message specifies it as a local variable. If False
or None
, the variable is treated as a non-local name.
See also
DataFrame.query
Query the columns of a DataFrame with a boolean expression.
DataFrame.eval
Evaluate a string describing operations on DataFrame columns.
Examples
df = pd.DataFrame({"A": [1, 1, 1]}) df.query("A > x")
... # UndefinedVariableError: name 'x' is not defined df.query("A > @y")
... # UndefinedVariableError: local variable 'y' is not defined pd.eval("x + 1")
... # UndefinedVariableError: name 'x' is not defined