{"record":{"id":"6abbfdce2d817b44","repo":"pandas-dev/pandas","slug":"name-is-not-a-supported-function","errorCode":null,"errorMessage":"\"{name}\" is not a supported function","messagePattern":"\"(.+?)\" is not a supported function","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"pandas/core/computation/ops.py","lineNumber":561,"sourceCode":"class MathCall(Op):\n    def __init__(self, func, args) -> None:\n        super().__init__(func.name, args)\n        self.func = func\n\n    def __call__(self, env):\n        # error: \"Op\" not callable\n        operands = [op(env) for op in self.operands]  # type: ignore[operator]\n        return self.func.func(*operands)\n\n    def __repr__(self) -> str:\n        operands = map(str, self.operands)\n        return pprint_thing(f\"{self.op}({','.join(operands)})\")\n\n\nclass FuncNode:\n    def __init__(self, name: str) -> None:\n        if name not in MATHOPS:\n            raise ValueError(f'\"{name}\" is not a supported function')\n        self.name = name\n        self.func = getattr(np, name)\n\n    def __call__(self, *args) -> MathCall:\n        return MathCall(self, args)\n","sourceCodeStart":543,"sourceCodeEnd":567,"githubUrl":"https://github.com/pandas-dev/pandas/blob/71959b8cb9b2459c16e14b34f28b178ccfe14735/pandas/core/computation/ops.py#L543-L567","documentation":"Raised by FuncNode.__init__ in pandas.core.computation.ops when a function call inside an eval/query expression names something not in MATHOPS (the union of _unary_math_ops like sin,cos,exp,log,... and _binary_math_ops arctan2). FuncNode wraps the call and binds it to the corresponding numpy function via getattr(np, name). The error is a ValueError.","triggerScenarios":"pd.eval('foo(a)') where 'foo' is not a whitelisted math function; df.query('isnan(a)'); pd.eval('len(a)'). Any function-call syntax in an eval string is checked against MATHOPS, and only those names resolve to numpy's implementations.","commonSituations":"Expecting arbitrary Python builtins (len, abs is allowed, round isn't) or numpy functions (isnan, isnan, vectorize) to be callable from eval. Also typoing a math function name (e.g. 'arcos' instead of 'arccos').","solutions":["Use only whitelisted math functions: sin, cos, tan, exp, log, expm1, log1p, sqrt, sinh, cosh, tanh, arcsin, arccos, arctan, arccosh, arcsinh, arctanh, abs, log10, floor, ceil, arctan2.","For non-whitelisted functions, precompute the result into a column/variable and reference that in eval, or apply the function directly to the Series outside eval.","Use @local_func(arg) only if it resolves from scope - but note pure function calls inside eval still go through FuncNode, so prefer precomputing."],"exampleFix":"# before\nimport pandas as pd\npd.eval('round(a, 2)')  # ValueError: \"round\" is not a supported function\n\n# after (precompute)\nimport numpy as np\ns = pd.Series([1.1, 2.6])\nrounded = np.round(s, 2)   # apply directly\n# or use a supported function:\npd.eval('floor(a)')        # 'floor' is whitelisted","handlingStrategy":"validation","validationCode":"from pandas.core.computation.ops import MATHOPS\n\ndef assert_supported_func(name: str) -> str:\n    if name not in MATHOPS:\n        raise ValueError(f'{name!r} not supported; whitelist: {MATHOPS}')\n    return name","typeGuard":"from pandas.core.computation.ops import MATHOPS\n\ndef is_supported_math_func(name: str) -> bool:\n    return name in MATHOPS\n","tryCatchPattern":"try:\n    pd.eval('foo(a)')\nexcept ValueError as e:\n    if 'not a supported function' in str(e):\n        # precompute and pass as a variable\n        a_computed = np.foo(a)\n    raise","preventionTips":["Only call whitelisted numpy math functions inside eval (sin, cos, exp, log, sqrt, abs, floor, ceil, arctan2, etc.).","Precompute non-whitelisted results into a variable/column and reference that.","Spell function names correctly (arccos not arcos)."],"tags":["pandas","eval","functions","math"],"analyzedSha":"71959b8cb9b2459c16e14b34f28b178ccfe14735","analyzedAt":"2026-08-07T01:30:20.476Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}