{"record":{"id":"6eeb1372e2c8fd18","repo":"apache/beam","slug":"key","errorCode":null,"errorMessage":"key","messagePattern":"key","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/dataframe/frames.py","lineNumber":2552,"sourceCode":"    elif isinstance(key, slice):\n      if _is_null_slice(key):\n        return self\n      elif _is_integer_slice(key):\n        # This depends on the contents of the index.\n        raise frame_base.WontImplementError(\n            \"Integer slices are not supported as they are ambiguous. Please \"\n            \"use iloc or loc with integer slices.\")\n      else:\n        return self.loc[key]\n\n    elif (\n        (isinstance(key, list) and all(key_column in self._expr.proxy().columns\n                                       for key_column in key)) or\n        key in self._expr.proxy().columns):\n      return self._elementwise(lambda df: df[key], 'get_column')\n\n    else:\n      raise NotImplementedError(key)\n\n  def __contains__(self, key):\n    # Checks if proxy has the given column\n    return self._expr.proxy().__contains__(key)\n\n  def __setitem__(self, key, value):\n    if isinstance(\n        key, str) or (isinstance(key, list) and\n                      all(isinstance(c, str)\n                          for c in key)) or (isinstance(key, DeferredSeries) and\n                                             key._expr.proxy().dtype == bool):\n      # yapf: disable\n      return self._elementwise(\n          lambda df, key, value: df.__setitem__(key, value),\n          'set_column',\n          (key, value),\n          inplace=True)\n    else:","sourceCodeStart":2534,"sourceCodeEnd":2570,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/dataframe/frames.py#L2534-L2570","documentation":"DeferredDataFrame.__getitem__ (df[key]) only supports selecting whole existing columns. If the key is not a list of known columns or a single known column name, the implementation cannot interpret it and raises NotImplementedError carrying the key object itself as the message.","triggerScenarios":"df['nonexistent_column']; df[new_columns_after_setitem] where the column was added out of band; df[['a', 'typo']]; indexing with a computed/renamed key not present in the proxy schema.","commonSituations":"Schema drift between the pandas proxy and the runtime data; typos in column names; attempting label-based row indexing (should be .loc) via df[some_row_label].","solutions":["Verify the column exists: print(df.columns) or check key in df before indexing.","Use df.loc[key] for row/label-based access instead of df[key].","Fix typos in the column name; compare with the proxy schema.","Create the new column first with df['new'] = ... before indexing it."],"exampleFix":"// before\ncol = df['valu']  # typo\n// after\nassert 'value' in df.columns\ncol = df['value']","handlingStrategy":"validation","validationCode":"keys = key if isinstance(key, list) else [key]\nmissing = [k for k in keys if k not in df.columns]\nif missing:\n    raise KeyError(f'columns not found: {missing}')","typeGuard":"def is_valid_column(df, key) -> bool:\n    keys = key if isinstance(key, list) else [key]\n    return all(k in df._expr.proxy().columns for k in keys)","tryCatchPattern":"try:\n    col = df[key]\nexcept NotImplementedError as e:\n    logger.error('Column selection failed, key=%r not in columns', e.args[0])\n    col = None","preventionTips":["Check key in df.columns before indexing.","Use .loc for row/label access.","Create columns with df['new'] = ... before selecting them.","Log the proxy schema when schema drift is suspected."],"tags":["python","apache-beam","dataframe","column-not-found"],"backgroundTag":"entity-not-found","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"}