MCPcopy
hub / github.com/pandas-dev/pandas / UndefinedVariableError

Class UndefinedVariableError

pandas/errors/__init__.py:718–755  ·  view source on GitHub ↗

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 Indi

Source from the content-addressed store, hash-verified

716
717
718class UndefinedVariableError(NameError):
719 """
720 Exception raised by ``query`` or ``eval`` when using an undefined variable name.
721
722 It will also specify whether the undefined variable is local or not.
723
724 Parameters
725 ----------
726 name : str
727 The name of the undefined variable.
728 is_local : bool or None, optional
729 Indicates whether the undefined variable is considered a local variable.
730 If ``True``, the error message specifies it as a local variable.
731 If ``False`` or ``None``, the variable is treated as a non-local name.
732
733 See Also
734 --------
735 DataFrame.query : Query the columns of a DataFrame with a boolean expression.
736 DataFrame.eval : Evaluate a string describing operations on DataFrame columns.
737
738 Examples
739 --------
740 >>> df = pd.DataFrame({"A": [1, 1, 1]})
741 >>> df.query("A > x") # doctest: +SKIP
742 ... # UndefinedVariableError: name 'x' is not defined
743 >>> df.query("A > @y") # doctest: +SKIP
744 ... # UndefinedVariableError: local variable 'y' is not defined
745 >>> pd.eval("x + 1") # doctest: +SKIP
746 ... # UndefinedVariableError: name 'x' is not defined
747 """
748
749 def __init__(self, name: str, is_local: bool | None = None) -> None:
750 base_msg = f"{name!r} is not defined"
751 if is_local:
752 msg = f"local variable {base_msg}"
753 else:
754 msg = f"name {base_msg}"
755 super().__init__(msg)
756
757
758class IndexingError(Exception):

Callers 2

resolveMethod · 0.90

Calls

no outgoing calls

Tested by 1