pandas-dev/pandas · error · ValueError
"{name}" is not a supported function
Error message
"{name}" is not a supported function What it means
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.
Source
Thrown at pandas/core/computation/ops.py:561
class MathCall(Op):
def __init__(self, func, args) -> None:
super().__init__(func.name, args)
self.func = func
def __call__(self, env):
# error: "Op" not callable
operands = [op(env) for op in self.operands] # type: ignore[operator]
return self.func.func(*operands)
def __repr__(self) -> str:
operands = map(str, self.operands)
return pprint_thing(f"{self.op}({','.join(operands)})")
class FuncNode:
def __init__(self, name: str) -> None:
if name not in MATHOPS:
raise ValueError(f'"{name}" is not a supported function')
self.name = name
self.func = getattr(np, name)
def __call__(self, *args) -> MathCall:
return MathCall(self, args)
View on GitHub (pinned to 71959b8cb9)
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.
Example fix
# before
import pandas as pd
pd.eval('round(a, 2)') # ValueError: "round" is not a supported function
# after (precompute)
import numpy as np
s = pd.Series([1.1, 2.6])
rounded = np.round(s, 2) # apply directly
# or use a supported function:
pd.eval('floor(a)') # 'floor' is whitelisted Defensive patterns
Strategy: validation
Validate before calling
from pandas.core.computation.ops import MATHOPS
def assert_supported_func(name: str) -> str:
if name not in MATHOPS:
raise ValueError(f'{name!r} not supported; whitelist: {MATHOPS}')
return name Type guard
from pandas.core.computation.ops import MATHOPS
def is_supported_math_func(name: str) -> bool:
return name in MATHOPS
Try / catch
try:
pd.eval('foo(a)')
except ValueError as e:
if 'not a supported function' in str(e):
# precompute and pass as a variable
a_computed = np.foo(a)
raise Prevention
- 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).
When it happens
Trigger: 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.
Common situations: 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').
Related errors
- Only named functions are supported
- Invalid function call {node.func.id}
- Function "{res.name}" does not support keyword arguments
- keyword error in function call '{node.func.id}'
- The '@' prefix is only supported by the pandas parser
AI-assisted analysis of pandas-dev/pandas@71959b8cb9 (2026-08-07).
Data as JSON: /api/errors/6abbfdce2d817b44.
Report an issue: GitHub.