Skip to main content
`Ctrl`+`K`

# pandas.errors.UndefinedVariableError

exception pandas.errors.UndefinedVariableError(name, is_local=None)

  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:
    name str

      The name of the undefined variable.

    is_local bool 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