{"record":{"id":"88ed7c6e4a303932","repo":"pandas-dev/pandas","slug":"passing-a-filterable-condition-to-a-non-table-inde","errorCode":null,"errorMessage":"passing a filterable condition to a non-table indexer [{self}]","messagePattern":"passing a filterable condition to a non-table indexer \\[(.+?)\\]","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"pandas/core/computation/pytables.py","lineNumber":347,"sourceCode":"                self.filter[2],\n            )\n        return self\n\n    def format(self):\n        \"\"\"return the actual filter format\"\"\"\n        return [self.filter]\n\n    # error: Signature of \"evaluate\" incompatible with supertype \"BinOp\"\n    def evaluate(self) -> Self | None:  # type: ignore[override]\n        if not self.is_valid:\n            raise ValueError(f\"query term is not valid [{self}]\")\n\n        rhs = self.conform(self.rhs)\n        values = list(rhs)\n\n        if self.op not in [\"==\", \"!=\"]:\n            if not self.is_in_table:\n                raise TypeError(\n                    f\"passing a filterable condition to a non-table indexer [{self}]\"\n                )\n            return None\n\n        if self.is_in_table and len(values) <= self._max_selectors:\n            return None\n        filter_op = self.generate_filter_op()\n        self.filter = (self.lhs.value, filter_op, Index(values))\n        return self\n\n    def generate_filter_op(self, invert: bool = False):\n        if (self.op == \"!=\" and not invert) or (self.op == \"==\" and invert):\n            return lambda axis, vals: ~axis.isin(vals)\n        else:\n            return lambda axis, vals: axis.isin(vals)\n\n\nclass JointFilterBinOp(FilterBinOp):","sourceCodeStart":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/pandas-dev/pandas/blob/71959b8cb9b2459c16e14b34f28b178ccfe14735/pandas/core/computation/pytables.py#L329-L365","documentation":"Raised by FilterBinOp.evaluate in pandas.core.computation.pytables when the operator is not '==' or '!=' (i.e. an inequality like <, >, <=, >=, in, not in) AND self.is_in_table is False. is_in_table checks that queryables has a non-None entry for the column. The error is a TypeError and signals that you are trying an inequality filter on a column that is not stored as a data_column (only equality/list membership can sometimes be optimized via the index).","triggerScenarios":"store.select('df', where='price > 100') where 'price' is not a data_column; store.select('df', where='date < 20200101') against a non-indexed date column.","commonSituations":"Default table writes only make the index queryable for inequalities; users assume all columns support range queries; using inequality on a string/categorical column without data_columns=True.","solutions":["Declare the column as a data_column when writing: store.put('df', df, format='table', data_columns=['price']).","Use equality/list membership if you cannot rewrite: where='price == 100' may still work for indexed columns, but inequalities require data_columns.","Filter in pandas after reading: df = store.get('df'); df[df['price'] > 100].","For range queries on the index, use the index column name directly (e.g. where='index > 100')."],"exampleFix":"# before\nstore.select('df', where='price > 100')  # TypeError: passing a filterable condition to a non-table indexer\n\n# after\ndf.to_hdf(path, 'df', format='table', data_columns=['price'])\nstore.select('df', where='price > 100')\n# or:\ndf = pd.read_hdf(path, 'df')\ndf[df['price'] > 100]","handlingStrategy":"validation","validationCode":"def supports_inequality(store, key, column) -> bool:\n    storer = store.get_storer(key)\n    data_cols = list(storer.data_columns or [])\n    idx_cols = [getattr(a, 'name', None) for a in (storer.index_axes or [])]\n    return column in data_cols or column in idx_cols\n\n# before store.select('df', where=f'{col} > 5'):\nif not supports_inequality(store, 'df', col):\n    raise TypeError(f'{col!r} must be a data_column for inequality queries')","typeGuard":"def is_data_column(store, key, column) -> bool:\n    try:\n        return column in (store.get_storer(key).data_columns or [])\n    except Exception:\n        return False\n","tryCatchPattern":"try:\n    store.select('df', where=f'{col} > 5')\nexcept TypeError as e:\n    if 'filterable condition' in str(e):\n        df = store.get('df')\n        result = df[df[col] > 5]\n    else:\n        raise","preventionTips":["Declare range-query columns as data_columns when writing.","Use the index column for inequalities when possible.","Read+filter in pandas for non-indexed columns."],"tags":["pandas","hdf5","pytables","where","data-columns"],"analyzedSha":"71959b8cb9b2459c16e14b34f28b178ccfe14735","analyzedAt":"2026-08-07T01:30:20.476Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}