pandas-dev/pandas · error · ValueError

No transform functions were provided

Error message

No transform functions were provided

What it means

Raised by `transform_dict_like` when the dict-like `func` argument passed to `DataFrame.transform` is empty (`len(func) == 0`). Pandas treats an empty mapping as a user error because there is no operation to perform and silently returning the frame would hide a likely upstream bug. The check fires before any normalization of the dict, so even `{}` after expansion triggers it.

Solutions

  1. Pass at least one column->function mapping: `df.transform({'col1': 'cumsum'})`.
  2. If building the dict dynamically, guard upstream: `if transform_spec: df.transform(transform_spec)`.
  3. Audit the code that constructs the dict to confirm it is not being emptied by an over-restrictive filter.

Example fix

// before
spec = {c: 'shift' for c in df.columns if c.startswith('z')}  # empty if no z* columns
df.transform(spec)
// after
spec = {c: 'shift' for c in df.columns if c.startswith('z')}
if spec:
    df.transform(spec)
Defensive patterns

Strategy: validation

Validate before calling

def transform_or_skip(df, spec):
    if not spec:
        return df  # or raise a clearer domain error
    return df.transform(spec)

Type guard

def is_nonempty_dict_spec(spec) -> bool:
    return isinstance(spec, dict) and len(spec) > 0

Try / catch

try:
    out = df.transform(spec)
except ValueError as e:
    if 'No transform functions' in str(e):
        out = df  # nothing to do
    else:
        raise

Prevention

When it happens

Trigger: Calling `df.transform({})`, `df.transform(dict())`, or programmatically building a dict of transforms that ends up empty (e.g. `df.transform({k: 'mean' for k in [] if some_condition})`). Also when a Series.transform receives an empty dict.

Common situations: Dynamic column-selection logic that filters down to zero columns but still calls transform; configuration-driven pipelines where the transform spec comes from a config file that is empty or fully filtered out; refactoring that leaves a placeholder empty dict.

Related errors


AI-assisted analysis of pandas-dev/pandas@3b7651241d (2026-08-11). Data as JSON: /api/errors/608f4b10479d9bde. Report an issue: GitHub.

Appendix: 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 3b7651241d)