{"record":{"id":"c79c3f4fee241be1","repo":"pola-rs/polars","slug":"separator-must-be-a-single-character-found-sep","errorCode":null,"errorMessage":"`separator` must be a single character; found {separator!r}","messagePattern":"`separator` must be a single character; found (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/config.py","lineNumber":651,"sourceCode":"        ...     thousands_separator=\".\",\n        ...     decimal_separator=\",\",\n        ...     float_precision=3,\n        ... ):\n        ...     print(df)\n        shape: (3, 1)\n        ┌───────────────┐\n        │             v │\n        │           --- │\n        │           f64 │\n        ╞═══════════════╡\n        │     9.876,543 │\n        │ 1.010.101,000 │\n        │  -123.456,780 │\n        └───────────────┘\n        \"\"\"\n        if isinstance(separator, str) and len(separator) != 1:\n            msg = f\"`separator` must be a single character; found {separator!r}\"\n            raise ValueError(msg)\n        plr.set_decimal_separator(sep=separator)\n        return cls\n\n    @classmethod\n    def set_thousands_separator(\n        cls, separator: str | bool | None = None\n    ) -> type[Config]:\n        \"\"\"\n        Set the thousands grouping separator character.\n\n        Parameters\n        ----------\n        separator : str, bool\n            Set True to use the default \",\" (thousands) and \".\" (decimal) separators.\n            Can also set a custom char, or set ``None`` to omit the separator.\n\n        See Also\n        --------","sourceCodeStart":633,"sourceCodeEnd":669,"githubUrl":"https://github.com/pola-rs/polars/blob/68506541d2de983056c9eb244e1ea05fab377dfc/py-polars/src/polars/config.py#L633-L669","documentation":"`pl.Config.set_decimal_separator(sep)` accepts a single-character string (e.g. ',' or '.'), a bool, or None. Any string whose length is not exactly 1 — multi-character sequences like ', ' or '.,', and the empty string '' — raises ValueError before the setting reaches the Rust core.","triggerScenarios":"`pl.Config.set_decimal_separator(', ')` (trailing space) or `set_decimal_separator('.,')`; also `set_decimal_separator('')` fails because an empty string has length 0.","commonSituations":"Configuring European-style number display ('1.234,50') and passing a two-character separator or a copy-pasted separator with whitespace.","solutions":["Pass exactly one character: `pl.Config.set_decimal_separator(',')`.","For full locale-style formatting, pair it: `pl.Config.set_thousands_separator('.')` after setting the decimal separator.","Pass None (or a bool) to reset — these bypass the single-character check."],"exampleFix":"# before\npl.Config.set_decimal_separator(\", \")  # ValueError: `separator` must be a single character\n\n# after\npl.Config.set_decimal_separator(\",\")\npl.Config.set_thousands_separator(\".\")","handlingStrategy":"validation","validationCode":"def set_decimal(sep: str | bool | None) -> None:\n    if isinstance(sep, str) and len(sep) != 1:\n        raise ValueError(f\"decimal separator must be a single character, got {sep!r}\")\n    pl.Config.set_decimal_separator(sep)","typeGuard":"def is_valid_separator(sep: object) -> bool:\n    return sep is None or isinstance(sep, bool) or (isinstance(sep, str) and len(sep) == 1)","tryCatchPattern":null,"preventionTips":["Strip whitespace from separator values sourced from user input/config files.","Store locale presets ('de' -> decimal ',', thousands '.') instead of raw separator strings."],"tags":["config","formatting","validation","display","polars"],"backgroundTag":"invalid-argument-value","analyzedSha":"68506541d2de983056c9eb244e1ea05fab377dfc","analyzedAt":"2026-08-19T12:15:06.350Z","contentChangedAt":"2026-08-19T12:15:06.350Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}