pandas.errors.UndefinedVariableError#
- exception pandas.errors.UndefinedVariableError(name, is_local=None)[source]#
- Exception raised by - queryor- evalwhen 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- Falseor- 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