{"record":{"id":"dd3952e8a77df3fe","repo":"apache/beam","slug":"unsupported-value-for-new-column-name-value-only-callables","errorCode":null,"errorMessage":"Unsupported value for new column '{name}': '{value}'. Only callables and DeferredSeries instances are supported. Other types make this operation sensitive to the order of the data","messagePattern":"Unsupported value for new column '(.+?)': '(.+?)'\\. Only callables and DeferredSeries instances are supported\\. Other types make this operation sensitive to the order of the data","errorType":"exception","errorClass":"WontImplementError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/dataframe/frames.py","lineNumber":2731,"sourceCode":"\n\n  @property  # type: ignore\n  @frame_base.with_docs_from(pd.DataFrame)\n  def axes(self):\n    return (self.index, self.columns)\n\n  @property  # type: ignore\n  @frame_base.with_docs_from(pd.DataFrame)\n  def dtypes(self):\n    return self._expr.proxy().dtypes\n\n  @frame_base.with_docs_from(pd.DataFrame)\n  def assign(self, **kwargs):\n    \"\"\"``value`` must be a ``callable`` or :class:`DeferredSeries`. Other types\n    make this operation order-sensitive.\"\"\"\n    for name, value in kwargs.items():\n      if not callable(value) and not isinstance(value, DeferredSeries):\n        raise frame_base.WontImplementError(\n            f\"Unsupported value for new column '{name}': '{value}'. Only \"\n            \"callables and DeferredSeries instances are supported. Other types \"\n            \"make this operation sensitive to the order of the data\",\n            reason=\"order-sensitive\")\n    return self._elementwise(\n        lambda df, *args, **kwargs: df.assign(*args, **kwargs),\n        'assign',\n        other_kwargs=kwargs)\n\n  @frame_base.with_docs_from(pd.DataFrame)\n  @frame_base.args_to_kwargs(pd.DataFrame)\n  @frame_base.populate_defaults(pd.DataFrame)\n  def explode(self, column, ignore_index):\n    # ignoring the index will not preserve it\n    preserves = (partitionings.Singleton() if ignore_index\n                 else partitionings.Index())\n    return frame_base.DeferredFrame.wrap(\n        expressions.ComputedExpression(","sourceCodeStart":2713,"sourceCodeEnd":2749,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/dataframe/frames.py#L2713-L2749","documentation":"DeferredDataFrame.assign rejects column values that are neither callables nor DeferredSeries. Scalars, lists, or plain pandas Series passed as a new column value would need to be broadcast positionally, which depends on the order of rows in the distributed data, so Beam raises WontImplementError with reason 'order-sensitive'.","triggerScenarios":"Calling `ddf.assign(col=<scalar | list | pd.Series | np.ndarray>)` — any kwargs value that is not callable and not a DeferredSeries.","commonSituations":"Porting `df.assign(total=[1,2,3])` or `df.assign(flag=0)` from a notebook to a Beam DataFrame transform; assigning a plain pandas Series column to a distributed frame.","solutions":["Pass a callable: ddf.assign(col=lambda df: <DeferredSeries expression>).","Wrap array-like values as DeferredSeries first, e.g. via beam.dataframe or DeferredSeries.from_monotonic... (construct from the same pipeline).","Compute constant columns with an elementwise expression over an existing column, e.g. lambda df: df.existing * 0 + value."],"exampleFix":"// before\nddf.assign(total=[1, 2, 3])\n\n// after\nddf.assign(total=lambda df: df['other_col'] * 0 + 1)  # or any callable returning DeferredSeries","handlingStrategy":"validation","validationCode":"for name, value in assign_kwargs.items():\n    if not callable(value) and not isinstance(value, DeferredSeries):\n        assign_kwargs[name] = lambda df, v=value: df[ref_col] * 0 + v  # or wrap as DeferredSeries","typeGuard":"def is_assignable(value) -> bool:\n    return callable(value) or isinstance(value, DeferredSeries)","tryCatchPattern":"from apache_beam.dataframe import frame_base\ntry:\n    out = ddf.assign(**kwargs)\nexcept frame_base.WontImplementError as e:\n    # convert offending columns to callables and retry\n    out = ddf.assign(**{k: (v if callable(v) or isinstance(v, DeferredSeries) else (lambda df, c=v: df[df.columns[0]] * 0 + c)) for k, v in kwargs.items()})","preventionTips":["Always pass callables to assign in Beam DataFrame code.","Never pass positional lists/Series as assign values in distributed contexts.","Review ported notebook code for scalar/list assign patterns."],"tags":["pandas","apache-beam","dataframe","order-sensitive"],"backgroundTag":"unsupported-operation","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}