{"record":{"id":"7992bb75db36b49b","repo":"apache/beam","slug":"concat-levels","errorCode":null,"errorMessage":"concat(levels)","messagePattern":"concat\\(levels\\)","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/dataframe/pandas_top_level_functions.py","lineNumber":102,"sourceCode":"  @staticmethod\n  @frame_base.args_to_kwargs(pd)\n  @frame_base.populate_defaults(pd)\n  def concat(\n      objs,\n      axis,\n      join,\n      ignore_index,\n      keys,\n      levels,\n      names,\n      verify_integrity,\n      sort,\n      copy):\n\n    if ignore_index:\n      raise NotImplementedError('concat(ignore_index)')\n    if levels:\n      raise NotImplementedError('concat(levels)')\n\n    if isinstance(objs, Mapping):\n      if keys is None:\n        keys = list(objs.keys())\n      objs = [objs[k] for k in keys]\n    else:\n      objs = list(objs)\n\n    if keys is None:\n      preserves_partitioning = partitionings.Arbitrary()\n    else:\n      # Index 0 will be a new index for keys, only partitioning by the original\n      # indexes (1 to N) will be preserved.\n      nlevels = min(o._expr.proxy().index.nlevels for o in objs)\n      preserves_partitioning = partitionings.Index(\n          [i for i in range(1, nlevels + 1)])\n\n    deferred_none = expressions.ConstantExpression(None)","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/dataframe/pandas_top_level_functions.py#L84-L120","documentation":"The Beam DataFrame API's pd.concat wrapper does not support the levels parameter (used with MultiIndex when keys are given). Passing a non-empty levels argument raises NotImplementedError before any processing.","triggerScenarios":"Calling pd.concat(objs, keys=[...], levels=[...]) on deferred Beam dataframes with an explicit levels list.","commonSituations":"Porting pandas code that builds custom MultiIndex hierarchies via concat with keys+levels.","solutions":["Omit the levels argument and let the index be built from keys only","Construct the desired MultiIndex after concatenation using set_axis or other supported index operations","Perform the concat in plain pandas outside the Beam DataFrame transform if levels semantics are required"],"exampleFix":"// before\npd.concat([df1, df2], keys=['a','b'], levels=[['a','b','c']])\n// after\npd.concat([df1, df2], keys=['a','b'])","handlingStrategy":"fallback","validationCode":"if levels:\n    levels = None  # not supported by Beam DataFrame concat","typeGuard":null,"tryCatchPattern":"try:\n    out = pd.concat(objs, keys=keys, levels=levels)\nexcept NotImplementedError:\n    out = pd.concat(objs, keys=keys)","preventionTips":["Drop levels from concat calls when targeting Beam dataframes","Build custom MultiIndexes after concatenation with supported operations","Keep keys/levels usage in plain-pandas sections of the codebase"],"tags":["python","apache-beam","dataframe","pandas","not-implemented"],"backgroundTag":"unsupported-operation","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}