pandas-dev/pandas · error · ValueError
" " is not a supported function
Error message
"{name}" is not a supported function What it means
Raised in FuncNode.__init__ when the requested function name is not in MATHOPS — the fixed whitelist of numpy math functions exposed through eval/query (sin, cos, tan, exp, log, expm1, log1p, sqrt, sinh, cosh, tanh, arcsin, arccos, arctan, arccosh, arcsinh, arctanh, abs, log10, floor, ceil, arctan2). FuncNode is the fallback constructor invoked when a call target is not resolvable in the user scope; if the name also misses the whitelist, this ValueError is raised and typically surfaces as the underlying cause of an UndefinedVariableError re-raise.
Solutions
- Use only whitelisted math function names; see MATHOPS in pandas/core/computation/ops.py.
- For np.isnan/np.isinf/np.where, compute in Python first and inject via @-local: mask = np.isnan(df['A']); df[mask].
- Pre-resolve custom functions in scope and reference them with @ prefix only if they accept positional Series args.
- Validate function names against MATHOPS before assembling a dynamic query string.
Example fix
// before
from pandas.core.computation.ops import FuncNode
FuncNode("isnan")
df.query("isnan(A)")
// after
mask = np.isnan(df['A'])
df[mask]
# or use the whitelist
df.query("sin(A) > 0.5") Defensive patterns
Strategy: validation
Validate before calling
import pandas.core.computation.ops as _ops
def is_supported_mathop(name: str) -> bool:
return name in _ops.MATHOPS
assert is_supported_mathop(fn_name), f'{fn_name} is not a supported function; see MATHOPS' Type guard
import pandas.core.computation.ops as _ops
from typing import Any
def is_mathop_name(name: Any) -> bool:
return isinstance(name, str) and name in _ops.MATHOPS Try / catch
try:
from pandas.core.computation.ops import FuncNode
FuncNode('isnan')
except ValueError as e:
if 'not a supported function' in str(e):
mask = np.isnan(df['A'])
else:
raise Prevention
- Validate function names against MATHOPS before assembling query strings.
- Precompute unsupported numpy functions (isnan, where, maximum) in Python and inject via @-locals.
- Keep a copy of the MATHOPS tuple near query-building code.
When it happens
Trigger: df.query('foo(A)') where 'foo' is neither in scope nor in MATHOPS (this ValueError is raised inside the fallback try, then caught and the original UndefinedVariableError is re-raised — but direct FuncNode('foo') construction surfaces it). Programmatic use of FuncNode to validate a function name.
Common situations: Typos in math function names ('arcsinh' vs 'arcsinh'). Expecting arbitrary numpy functions (np.where, np.maximum, np.isnan) to be available in eval. Building query strings dynamically and forgetting to whitelist/escape custom functions.
Related errors
- Function " " does not support keyword arguments
- Invalid function call
- cannot evaluate scalar only bool ops
- keyword error in function call
- N-dimensional objects, where N > 2, are not supported with…
AI-assisted analysis of pandas-dev/pandas@3b7651241d (2026-08-11).
Data as JSON: /api/errors/6abbfdce2d817b44.
Report an issue: GitHub.
Appendix: 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 3b7651241d)