{"record":{"id":"d0352ab316d7f81d","repo":"pandas-dev/pandas","slug":"cannot-process-expression-self-expr-self","errorCode":null,"errorMessage":"cannot process expression [{self.expr}], [{self}] is not a valid condition","messagePattern":"cannot process expression \\[(.+?)\\], \\[(.+?)\\] is not a valid condition","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"pandas/core/computation/pytables.py","lineNumber":646,"sourceCode":"                self.env,\n                queryables=queryables,\n                parser=\"pytables\",\n                engine=\"pytables\",\n                encoding=encoding,\n            )\n            self.terms = self.parse()\n\n    def __repr__(self) -> str:\n        if self.terms is not None:\n            return pprint_thing(self.terms)\n        return pprint_thing(self.expr)\n\n    def evaluate(self):\n        \"\"\"create and return the numexpr condition and filter\"\"\"\n        try:\n            self.condition = self.terms.prune(ConditionBinOp)\n        except AttributeError as err:\n            raise ValueError(\n                f\"cannot process expression [{self.expr}], [{self}] \"\n                \"is not a valid condition\"\n            ) from err\n        try:\n            self.filter = self.terms.prune(FilterBinOp)\n        except AttributeError as err:\n            raise ValueError(\n                f\"cannot process expression [{self.expr}], [{self}] \"\n                \"is not a valid filter\"\n            ) from err\n\n        return self.condition, self.filter\n\n\nclass TermValue:\n    \"\"\"hold a term value that we use to construct a condition/filter\"\"\"\n\n    def __init__(self, value, converted, kind: str) -> None:","sourceCodeStart":628,"sourceCodeEnd":664,"githubUrl":"https://github.com/pandas-dev/pandas/blob/3b7651241d4da534b3559b60ef128e1c34f54116/pandas/core/computation/pytables.py#L628-L664","documentation":"Raised by PyTablesExpr.evaluate when self.terms.prune(ConditionBinOp) raises AttributeError, meaning the parsed expression cannot be reduced to a numexpr boolean condition. numexpr only handles indexable/data_column comparisons, so an expression that is a bare term, references a non-queryable column, or doesn't bottom out in a comparison produces this ValueError.","triggerScenarios":"store.select('df', where='A') where A is a bare column with no comparison; querying a column that was not stored as a data_column and is not the index; using an expression whose terms are pure FilterBinOps (membership/in-table lookups) that yield no numexpr condition; arithmetic-only predicates.","commonSituations":"Forgetting to declare data_columns=True when writing the HDF5 table, then trying to where-filter on those columns; mixing a filterable (in) clause with no actual condition; assuming every column is queryable when only indexed columns and declared data_columns are.","solutions":["Rewrite the store with data_columns specifying the columns you query on: store.put('df', df, format='table', data_columns=['A','B']).","Make the where clause a real boolean comparison, e.g. store.select('df', where='A > 5').","If the column is non-queryable, read the frame and filter in pandas: df = store.get('df'); df = df[df.A > 5].","Verify the queryable columns with store.get_storer('df').non_index_axes / data_columns before selecting."],"exampleFix":"// before\nstore.put('df', df, format='table')\nstore.select('df', where='A > 5')  # A not a data_column -> invalid condition\n\n// after\nstore.put('df', df, format='table', data_columns=['A'])\nstore.select('df', where='A > 5')","handlingStrategy":"validation","validationCode":"storer = store.get_storer('df')\nqueryable = set(getattr(storer, 'data_columns', []) or []) | {storer.index.name} if storer.index.name else set()\nneeded = {'A'}\nmissing = needed - queryable\nif missing:\n    raise ValueError(f'columns not queryable (re-write with data_columns): {missing}')","typeGuard":null,"tryCatchPattern":"try:\n    selected = store.select('df', where='A > 5')\nexcept ValueError as err:\n    if 'is not a valid condition' in str(err):\n        df = store.get('df')\n        selected = df[df['A'] > 5]\n    else:\n        raise","preventionTips":["Write tables with data_columns listing every column you intend to query.","Prefer real boolean comparisons in where clauses over bare column names.","Cache and reuse the same store schema rather than re-creating without data_columns."],"tags":["pytables","hdf5","numexpr","where-clause","data-column"],"backgroundTag":null,"analyzedSha":"3b7651241d4da534b3559b60ef128e1c34f54116","analyzedAt":"2026-08-11T22:10:44.015Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}