{"record":{"id":"f77100c078b5eb70","repo":"apache/beam","slug":"align-copy-false-is-not-supported-because-it-might-be-an","errorCode":null,"errorMessage":"align(copy=False) is not supported because it might be an inplace operation depending on the data. Please prefer the default align(copy=True).","messagePattern":"align\\(copy=False\\) is not supported because it might be an inplace operation depending on the data\\. Please prefer the default align\\(copy=True\\)\\.","errorType":"exception","errorClass":"WontImplementError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/dataframe/frames.py","lineNumber":2588,"sourceCode":"    else:\n      raise NotImplementedError(key)\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 align(self, other, join, axis, copy, level, method, **kwargs):\n    \"\"\"Aligning per level is not yet supported. Only the default,\n    ``level=None``, is allowed.\n\n    Filling NaN values via ``method`` is not supported, because it is\n    `order-sensitive\n    <https://s.apache.org/dataframe-order-sensitive-operations>`_. Only the\n    default, ``method=None``, is allowed.\n\n    ``copy=False`` is not supported because its behavior (whether or not it is\n    an inplace operation) depends on the data.\"\"\"\n    if not copy:\n      raise frame_base.WontImplementError(\n          \"align(copy=False) is not supported because it might be an inplace \"\n          \"operation depending on the data. Please prefer the default \"\n          \"align(copy=True).\")\n    if method is not None and method != lib.no_default:\n      raise frame_base.WontImplementError(\n          f\"align(method={method!r}) is not supported because it is \"\n          \"order sensitive. Only align(method=None) is supported.\",\n          reason=\"order-sensitive\")\n    if kwargs:\n      raise NotImplementedError('align(%s)' % ', '.join(kwargs.keys()))\n\n    # In Pandas 2.0, all aggregations lost the level keyword.\n    if PD_VERSION < (2, 0) and level is not None:\n      # Could probably get by partitioning on the used levels.\n      requires_partition_by = partitionings.Singleton(reason=(\n          f\"align(level={level}) is not currently parallelizable. Only \"\n          \"align(level=None) can be parallelized.\"))\n    elif axis in ('columns', 1):","sourceCodeStart":2570,"sourceCodeEnd":2606,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/dataframe/frames.py#L2570-L2606","documentation":"DeferredFrame.align(copy=False) is rejected because in pandas copy=False may or may not be an inplace operation depending on the data (whether indexes already match), introducing data-dependent behavior. Beam's dataframe API requires the default copy=True and raises WontImplementError otherwise.","triggerScenarios":"Calling align(other, copy=False) on any DeferredDataFrame/Series, typically as a micro-optimization ported from pandas code.","commonSituations":"Copying pandas performance tweaks (copy=False to avoid copies) into Beam pipelines; code sharing an align helper between pandas and Beam dataframes.","solutions":["Remove copy=False and use the default align(other) (copy=True)","If avoiding copies mattered, restructure to join/merge or reindex explicitly where copy semantics are clear"],"exampleFix":"// before\nl, r = left.align(right, copy=False)\n// after\nl, r = left.align(right)","handlingStrategy":"validation","validationCode":"assert kwargs.get('copy', True) is True, 'align(copy=False) unsupported on deferred frames'","typeGuard":"def beam_safe_align_kwargs(kwargs):\n    return kwargs.get('copy', True)","tryCatchPattern":"from apache_beam.dataframe import frame_base\ntry:\n    l, r = left.align(right)\nexcept frame_base.WontImplementError:\n    l, r = left.align(right)  # drop copy=False","preventionTips":["Do not port pandas copy=False micro-optimizations into Beam dataframe code","Rely on the deferred API's copy semantics instead of in-place tricks","Audit shared pandas/Beam helper functions for copy=False arguments"],"tags":["pandas","apache-beam","dataframe","data-dependent-behavior"],"backgroundTag":"invalid-argument-value","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"}