{"record":{"id":"aed0ef038c9eea99","repo":"apache/beam","slug":"index-s","errorCode":null,"errorMessage":"index.%s","messagePattern":"index\\.(.+?)","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/dataframe/frames.py","lineNumber":4902,"sourceCode":"\n  @name.setter\n  def name(self, value):\n    self.names = [value]\n\n  @property\n  def ndim(self):\n    return self._frame._expr.proxy().index.ndim\n\n  @property\n  def dtype(self):\n    return self._frame._expr.proxy().index.dtype\n\n  @property\n  def nlevels(self):\n    return self._frame._expr.proxy().index.nlevels\n\n  def __getattr__(self, name):\n    raise NotImplementedError('index.%s' % name)\n\n\n@populate_not_implemented(pd.core.indexing._LocIndexer)\nclass _DeferredLoc(object):\n  def __init__(self, frame):\n    self._frame = frame\n\n  def __getitem__(self, key):\n    if isinstance(key, tuple):\n      rows, cols = key\n      return self[rows][cols]\n    elif isinstance(key, list) and key and isinstance(key[0], bool):\n      # Aligned by numerical key.\n      raise NotImplementedError(type(key))\n    elif isinstance(key, list):\n      # Select rows, but behaves poorly on missing values.\n      raise NotImplementedError(type(key))\n    elif isinstance(key, slice):","sourceCodeStart":4884,"sourceCodeEnd":4920,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/dataframe/frames.py#L4884-L4920","documentation":"_DeferredIndex.__getattr__ raises NotImplementedError('index.<name>') for any attribute accessed on the deferred .index object that is not explicitly implemented (like nlevels). Beam only supports a small whitelist of index operations on deferred frames.","triggerScenarios":"Accessing attributes/methods on df.index of a Beam deferred DataFrame such as df.index.name, df.index.unique(), df.index.map(...), or any property not explicitly defined.","commonSituations":"Pandas code that inspects or manipulates the index after reads; debugging code printing df.index details inside a Beam pipeline; IDE-generated attribute access.","solutions":["Avoid index attribute access in deferred (lazy) code; compute needed index info eagerly on a small sample or outside the pipeline.","Use supported operations only, or reset_index()/operate on columns instead of the index.","Force computation with .to_pandas() on a small test dataset to inspect the index locally."],"exampleFix":"# before\nresult = beam_df.index.unique()\n# after\nresult = beam_df.reset_index().drop_duplicates(subset='index')['index']","handlingStrategy":"type-guard","validationCode":"ALLOWED = {'nlevels'}\nassert attr in ALLOWED, 'Deferred index attribute %r is unsupported in Beam' % attr","typeGuard":"def is_supported_index_attr(name: str) -> bool:\n    return name in {'nlevels'}","tryCatchPattern":"try:\n    val = beam_df.index.<attr>\nexcept NotImplementedError as e:\n    if str(e).startswith('index.'):\n        val = beam_df.to_pandas().index.<attr>  # only on small/sample data","preventionTips":["Treat deferred .index as read-only with a tiny API surface.","Compute index metadata eagerly on sample data outside the pipeline.","Prefer reset_index() and column operations over index manipulation."],"tags":["apache-beam","dataframe","not-implemented","index"],"backgroundTag":"method-not-implemented","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"}