pandas-dev/pandas · error · ValueError
No transform functions were provided
Error message
No transform functions were provided
What it means
Raised inside `transform_dict_like` when the dict of transform functions is empty (`{}`). With no functions specified, there is nothing to compute, so pandas raises rather than silently returning an empty result. This typically happens when the dict is built programmatically and ends up empty.
Source
Thrown at pandas/core/apply.py:423
):
raise ValueError("Function did not transform")
return result
def transform_dict_like(self, func) -> DataFrame:
"""
Compute transform in the case of a dict-like func
"""
obj = self.obj
args = self.args
kwargs = self.kwargs
# transform is currently only for Series/DataFrame
assert isinstance(obj, ABCNDFrame)
if len(func) == 0:
raise ValueError("No transform functions were provided")
func = self.normalize_dictlike_arg("transform", obj, func)
results: dict[Hashable, DataFrame | Series] = {}
for name, how in func.items():
colg = obj._gotitem(name, ndim=1)
results[name] = colg.transform(how, 0, *args, **kwargs)
return concat(results, axis=1)
def transform_str_or_callable(self, func) -> DataFrame | Series:
"""
Compute transform in the case of a string or callable func
"""
obj = self.obj
args = self.args
kwargs = self.kwargs
if isinstance(func, str):View on GitHub (pinned to 71959b8cb9)
Solutions
- Guard before calling transform: `if func_dict: df.transform(func_dict)`.
- Inspect the source of the dict to ensure at least one valid mapping is present.
- Provide a sensible default entry in the dict construction.
Example fix
# before
df.transform({k: ['mean'] for k in [] })
# after
ops = {c: ['mean'] for c in df.select_dtypes('number').columns}
if ops:
df.transform(ops) Defensive patterns
Strategy: validation
Validate before calling
def safe_transform(df, func_dict):
if not func_dict:
raise ValueError('transform dict must be non-empty')
return df.transform(func_dict) Type guard
def is_nonempty_dict(d) -> bool:
return isinstance(d, dict) and len(d) > 0 Try / catch
try:
df.transform(func_dict)
except ValueError as e:
if 'No transform functions were provided' in str(e):
# nothing to do; return input unchanged
return df
raise Prevention
- Guard `if func_dict:` before calling transform.
- Build function dicts from sources known to be non-empty.
When it happens
Trigger: `df.transform({})`, or `df.transform({k: v for k, v in d.items() if condition})` where the comprehension produces an empty dict. Also calling transform on a GroupBy with an empty dict.
Common situations: Filtering a function/col dict dynamically such that all entries are filtered out; refactoring that leaves an empty default; logic errors where the dict is never populated.
Related errors
- invalid value for result_type, must be one of {None, 'reduce
- Function names must be unique if there is no new column name
- Transform function failed
- Function did not transform
- cannot combine transform and aggregation operations
AI-assisted analysis of pandas-dev/pandas@71959b8cb9 (2026-08-07).
Data as JSON: /api/errors/608f4b10479d9bde.
Report an issue: GitHub.