{"record":{"id":"6041f2c2e3f7fb84","repo":"pola-rs/polars","slug":"selecting-rows-by-passing-a-boolean-mask-to-get","errorCode":null,"errorMessage":"selecting rows by passing a boolean mask to `__getitem__` is not supported\\n\\nHint: Use the `filter` method instead.","messagePattern":"selecting rows by passing a boolean mask to `__getitem__` is not supported\\\\n\\\\nHint: Use the `filter` method instead\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/_utils/getitem.py","lineNumber":457,"sourceCode":"        else:\n            if arr.dtype in (np.int8, np.int16, np.int32):\n                arr = arr.astype(np.int64)\n\n        # Update negative indexes to absolute indexes.\n        arr = np.where(arr < 0, size + arr, arr)\n\n    # numpy conversion is much faster\n    arr = arr.astype(np.uint32) if idx_type == UInt32 else arr.astype(np.uint64)\n\n    return pl.Series(\"\", arr, dtype=idx_type)\n\n\ndef _raise_on_boolean_mask() -> NoReturn:\n    msg = (\n        \"selecting rows by passing a boolean mask to `__getitem__` is not supported\"\n        \"\\n\\nHint: Use the `filter` method instead.\"\n    )\n    raise TypeError(msg)\n","sourceCodeStart":439,"sourceCodeEnd":458,"githubUrl":"https://github.com/pola-rs/polars/blob/9b5d73fd00236295624374b075d16b1fe6ec6df9/py-polars/src/polars/_utils/getitem.py#L439-L458","documentation":"TypeError raised by _raise_on_boolean_mask, a shared helper called from Series/DataFrame __getitem__ and index-conversion paths whenever a boolean mask is supplied where row selection by mask is not allowed. The message directs users to the filter method, which is the supported masking API.","triggerScenarios":"Boolean mask passed to __getitem__ for row selection.","commonSituations":"See trigger scenarios.","solutions":["Use df.filter(mask) instead of df[mask] for row filtering."],"exampleFix":"df.filter(pl.col('a') > 0)","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9b5d73fd00236295624374b075d16b1fe6ec6df9","analyzedAt":"2026-08-19T12:15:06.350Z","contentChangedAt":"2026-08-19T12:15:06.350Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}