{"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":3694,"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":3676,"sourceCodeEnd":3712,"githubUrl":"https://github.com/pandas-dev/pandas/blob/3b7651241d4da534b3559b60ef128e1c34f54116/pandas/core/arrays/arrow/array.py#L3676-L3712","documentation":"Raised by ArrowExtensionArray._str_extract when the regex `flags` argument is non-zero. The PyArrow-backed string `str.extract` delegates to pyarrow.compute.extract_regex, which has no parameter for re-style flags (IGNORECASE, MULTILINE, etc.), so pandas can only honor flags=0. Passing any flag value short-circuits before compilation.","triggerScenarios":"Calling `ser.str.extract(pat, flags=re.IGNORECASE)` (or any non-zero flag) on a Series backed by a pyarrow dtype (e.g. ArrowExtensionArray of string[pyarrow]). Also triggered via `.extractall` routes that funnel into `_str_extract`.","commonSituations":"Copying working regex code from a numpy/object-string Series onto a pyarrow-backed Series; enabling pyarrow string dtype as the default and forgetting that the arrow path is more restrictive than the object path.","solutions":["Drop the flags argument (use flags=0, the default) and instead embed the flag semantics directly in the pattern, e.g. use `(?i)...` for IGNORECASE, `(?m)...` for MULTILINE.","If inline flags are insufficient, cast the Series to object dtype first (`ser.astype(object)`) so the numpy/object str.extract path handles the flags."],"exampleFix":"# before\nser.str.extract(r\"(?P<word>[a-z]+)\", flags=re.IGNORECASE)\n# after\nser.str.extract(r\"(?i)(?P<word>[a-z]+)\")","handlingStrategy":"validation","validationCode":"import re\n# Validate that flags is zero before calling .str.extract on arrow strings\nif flags := getattr(my_flags, \"value\", my_flags):\n    raise ValueError(f\"flags={flags} unsupported on string[pyarrow]; inline the flag in pat instead\")\nser.str.extract(pat, flags=0)","typeGuard":"def supports_extract_flags(ser) -> bool:\n    # arrow path does not support flags; object path does\n    return ser.dtype == object","tryCatchPattern":"try:\n    out = ser.str.extract(pat, flags=flags)\nexcept NotImplementedError as e:\n    if \"flags=0\" in str(e):\n        out = ser.astype(object).str.extract(pat, flags=flags)\n    else:\n        raise","preventionTips":["Inline re flags as (?i)/(?m) groups for arrow string dtypes","Cast to object dtype before str.extract if you rely on flag semantics"],"tags":["pyarrow","string-accessor","regex","not-implemented","arrow-extension"],"backgroundTag":null,"analyzedSha":"3b7651241d4da534b3559b60ef128e1c34f54116","analyzedAt":"2026-08-11T22:10:44.015Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}