pandas-dev/pandas · error · NotImplementedError

Parallel apply is not supported when raw=False and…

Error message

Parallel apply is not supported when raw=False and engine='numba'

What it means

Raised by apply_series_numba when engine='numba' is used with raw=False (the default, where the function receives a Series per row) and engine_kwargs contains {'parallel': True}. The numba backend's Series-based apply path has no parallel implementation, so pandas refuses to run rather than silently ignoring the parallel flag.

Solutions

  1. Remove 'parallel' from engine_kwargs (default engine_kwargs={}, single-threaded numba).
  2. If parallel execution is required, switch to engine='numba' with raw=True so the function receives numpy values and the parallel numba path applies.
  3. Drop numba and use the default python engine, which supports the existing Series func unchanged.

Example fix

# before
df.apply(func, engine='numba', engine_kwargs={'parallel': True})
# after
df.apply(func, engine='numba')
Defensive patterns

Strategy: validation

Validate before calling

def safe_numba_apply(obj, func, **kwargs):
    ek = kwargs.get('engine_kwargs') or {}
    if kwargs.get('engine') == 'numba' and ek.get('parallel', False):
        raise ValueError("parallel=True is not supported with engine='numba' and raw=False; dropping parallel")
    return obj.apply(func, **kwargs)

Try / catch

try:
    df.apply(func, engine='numba', engine_kwargs=ek)
except NotImplementedError as e:
    if 'Parallel apply' in str(e):
        df.apply(func, engine='numba')  # fall back to single-threaded numba
    else:
        raise

Prevention

When it happens

Trigger: df.apply(func, engine='numba', engine_kwargs={'parallel': True}) where func expects a Series; Series.apply(func, engine='numba', engine_kwargs={'parallel': True}).

Common situations: Developers switch on numba expecting speed and additionally enable parallel=True (copied from a tutorial or numba.jit example) without realizing the Series apply path is single-threaded only.

Related errors


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

Appendix: source

Thrown at pandas/core/apply.py:1307

        assert callable(self.func)

        series_gen = self.series_generator
        res_index = self.result_index

        results = {}

        for i, v in enumerate(series_gen):
            results[i] = self.func(v, *self.args, **self.kwargs)
            if isinstance(results[i], ABCSeries):
                # If we have a view on v, we need to make a copy because
                #  series_generator will swap out the underlying data
                results[i] = results[i].copy(deep=False)

        return results, res_index

    def apply_series_numba(self):
        if self.engine_kwargs.get("parallel", False):
            raise NotImplementedError(
                "Parallel apply is not supported when raw=False and engine='numba'"
            )
        if not self.obj.index.is_unique or not self.columns.is_unique:
            raise NotImplementedError(
                "The index/columns must be unique when raw=False and engine='numba'"
            )
        self.validate_values_for_numba()
        results = self.apply_with_numba()
        return results, self.result_index

    def wrap_results(self, results: ResType, res_index: Index) -> DataFrame | Series:
        from pandas import Series

        # see if we can infer the results
        if len(results) > 0 and 0 in results and is_sequence(results[0]):
            return self.wrap_results_for_axis(results, res_index)

        # dict of scalars

View on GitHub (pinned to 3b7651241d)