{"record":{"id":"4ba6bbda82844089","repo":"pandas-dev/pandas","slug":"only-flags-0-is-implemented","errorCode":null,"errorMessage":"Only flags=0 is implemented.","messagePattern":"Only flags=0 is implemented\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"pandas/core/arrays/arrow/array.py","lineNumber":3666,"sourceCode":"\n    def _str_rpartition(self, sep: str, expand: bool) -> Self:\n        predicate = lambda val: val.rpartition(sep)\n        result = self._apply_elementwise(predicate)\n        return self._from_pyarrow_array(pa.chunked_array(result))\n\n    def _str_casefold(self) -> Self:\n        predicate = lambda val: val.casefold()\n        result = self._apply_elementwise(predicate)\n        return self._from_pyarrow_array(pa.chunked_array(result))\n\n    def _str_encode(self, encoding: str, errors: str = \"strict\") -> Self:\n        predicate = lambda val: val.encode(encoding, errors)\n        result = self._apply_elementwise(predicate)\n        return self._from_pyarrow_array(pa.chunked_array(result))\n\n    def _str_extract(self, pat: str, flags: int = 0, expand: bool = True):\n        if flags:\n            raise NotImplementedError(\"Only flags=0 is implemented.\")\n        groups = re.compile(pat).groupindex.keys()\n        if len(groups) == 0:\n            raise ValueError(f\"{pat=} must contain a symbolic group name.\")\n        result = pc.extract_regex(self._pa_array, pat)\n        if expand:\n            return {\n                col: self._from_pyarrow_array(pc.struct_field(result, [i]))\n                for col, i in zip(groups, range(result.type.num_fields), strict=True)\n            }\n        else:\n            return type(self)(pc.struct_field(result, [0]))\n\n    def _str_findall(self, pat: str, flags: int = 0) -> Self:\n        regex = re.compile(pat, flags=flags)\n        predicate = lambda val: regex.findall(val)\n        result = self._apply_elementwise(predicate)\n        return self._from_pyarrow_array(pa.chunked_array(result))\n","sourceCodeStart":3648,"sourceCodeEnd":3684,"githubUrl":"https://github.com/pandas-dev/pandas/blob/71959b8cb9b2459c16e14b34f28b178ccfe14735/pandas/core/arrays/arrow/array.py#L3648-L3684","documentation":"Raised by ArrowExtensionArray._str_extract when the `flags` argument is non-zero. The PyArrow compute function pc.extract_regex does not accept regex flags, so the ArrowExtensionArray implementation rejects any non-zero flags with NotImplementedError. This is reached through Series.str.extract / str.extractall on a pyarrow-string-backed Series.","triggerScenarios":"Calling `s.str.extract(pat, flags=re.IGNORECASE)` (or any re module flag such as re.VERBOSE, re.MULTILINE) where `s.dtype` is a pyarrow-backed string dtype (string[pyarrow] / large string). flags=0 is the only supported value.","commonSituations":"Case-insensitive extraction patterns written with re.IGNORECASE that worked on object/string[python] dtypes fail when the column is converted to string[pyarrow] for memory/performance reasons. Shared regex utility functions that pass flags unconditionally.","solutions":["Inline the flag into the pattern itself, e.g. replace `re.IGNORECASE` with an inline `(?i)` group: `s.str.extract(r\"(?i)(?P<name>\\\\w+)\")`.","Drop the flags argument (default flags=0) and make the pattern explicit for the cases you need.","Cast the Series to object/string[python] for that operation: `s.astype(\"string[python]\").str.extract(pat, flags=re.IGNORECASE)`.","Pre-compile and lowercase both sides instead of relying on regex flags."],"exampleFix":"# before\ns = pd.Series([\"Foo\",\"bar\"], dtype=\"string[pyarrow]\")\ns.str.extract(r\"(?P<w>foo)\", flags=re.IGNORECASE)  # NotImplementedError\n\n# after: embed flag inline\ns.str.extract(r\"(?i)(?P<w>foo)\")","handlingStrategy":"validation","validationCode":"def safe_extract(s, pat, flags=0):\n    if flags:\n        # pyarrow backend only supports flags=0; bake flag into pattern\n        import re as _re\n        pat = _re.compile(pat, flags).pattern  # note: does not inline flags; see tip\n        raise NotImplementedError(\"Use inline (?i)/(?x) in pattern for string[pyarrow]\")\n    return s.str.extract(pat)","typeGuard":"def flags_ok_for_pyarrow(flags: int) -> bool:\n    return not flags","tryCatchPattern":"try:\n    out = s.str.extract(pat, flags=flags)\nexcept NotImplementedError:\n    out = s.astype(\"string[python]\").str.extract(pat, flags=flags)","preventionTips":["Prefer inline regex flags ((?i), (?x), (?m)) over the flags= argument for portable patterns.","Centralize regex helpers so backend differences are handled in one place.","Unit-test extraction utilities against string[pyarrow] dtypes."],"tags":["pyarrow","string-accessor","regex","not-implemented"],"analyzedSha":"71959b8cb9b2459c16e14b34f28b178ccfe14735","analyzedAt":"2026-08-07T01:30:20.476Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}