{"record":{"id":"748a38d45b16941d","repo":"pandas-dev/pandas","slug":"no-such-keys-s-pat-r","errorCode":null,"errorMessage":"No such keys(s): {pat!r}","messagePattern":"No such keys\\(s\\): (.+?)","errorType":"exception","errorClass":"OptionError","httpStatus":null,"severity":"error","filePath":"pandas/_config/config.py","lineNumber":132,"sourceCode":"    Examples\n    --------\n    >>> pd.options.context\n    Traceback (most recent call last):\n    OptionError: No such option\n    \"\"\"\n\n    __module__ = \"pandas.errors\"\n\n\n#\n# User API\n\n\ndef _get_single_key(pat: str) -> str:\n    keys = _select_options(pat)\n    if len(keys) == 0:\n        _warn_if_deprecated(pat)\n        raise OptionError(f\"No such keys(s): {pat!r}\")\n    if len(keys) > 1:\n        raise OptionError(\"Pattern matched multiple keys\")\n    key = keys[0]\n\n    _warn_if_deprecated(key)\n\n    key = _translate_key(key)\n\n    return key\n\n\ndef get_option(pat: str) -> Any:\n    \"\"\"\n    Retrieve the value of the specified option.\n\n    This method allows users to query the current value of a given option\n    in the pandas configuration system. Options control various display,\n    performance, and behavior-related settings within pandas.","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/pandas-dev/pandas/blob/3b7651241d4da534b3559b60ef128e1c34f54116/pandas/_config/config.py#L114-L150","documentation":"Raised by `_get_single_key` (used by `get_option` and `set_option`) when `_select_options(pat)` returns zero matches. `pat` is treated case-insensitively and as a regex via `re.search`, with an exact-match short-circuit. If nothing in `_registered_options` matches, this OptionError (subclass of AttributeError and KeyError) is thrown after checking for deprecation warnings.","triggerScenarios":"`pd.get_option('display.max_colmns')` (typo), `pd.set_option('foo.bar', 1)` where `foo.bar` was never registered, or any pattern that matches no registered option key.","commonSituations":"Typo in an option name; using an option that was removed/renamed in a newer pandas version; copy-pasting an option name from an outdated tutorial; case confusion is rare (keys are lowercased) but regex special chars in the pattern matching nothing.","solutions":["List/inspect available options with `pd.describe_option()` (no arg lists all) to find the correct name.","Use the fully-qualified key, e.g. `pd.get_option('display.max_columns')`, not an abbreviation.","Check the pandas version and the changelog if the option existed before — it may have been renamed/removed.","Escape regex metacharacters if your pattern intentionally contains `.`, `*`, etc."],"exampleFix":"# before\npd.get_option('display.max_colmns')   # typo -> OptionError\n\n# after\npd.describe_option()                  # find the real name\npd.get_option('display.max_columns')","handlingStrategy":"validation","validationCode":"import pandas as pd\nfrom pandas._config.config import _select_options\ndef option_exists(pat: str) -> bool:\n    return len(_select_options(pat)) == 1\nif option_exists('display.max_columns'):\n    val = pd.get_option('display.max_columns')","typeGuard":"def is_known_option(pat: str) -> bool:\n    import pandas._config.config as c\n    return len(c._select_options(pat)) == 1","tryCatchPattern":"from pandas.errors import AbstractMethodError  # placeholder; OptionError lives in pandas._config.config\nfrom pandas._config.config import OptionError\ntry:\n    pd.get_option(maybe_bad_key)\nexcept OptionError as e:\n    # handle unknown option (also caught by KeyError/AttributeError base classes)\n    ...","preventionTips":["Always use the fully-qualified option key from `pd.describe_option()`.","Treat option names as part of your public API: pin pandas version if you rely on partial matches.","Validate user-supplied option strings against `_select_options` before get/set.","Escape regex metacharacters when option patterns come from external input."],"tags":["config","option","typo","api-misuse","option-error"],"backgroundTag":null,"analyzedSha":"3b7651241d4da534b3559b60ef128e1c34f54116","analyzedAt":"2026-08-11T22:10:44.015Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}