pandas-dev/pandas · error · OptionError
No such keys(s) for
Error message
No such keys(s) for {pat=} What it means
Raised by `describe_option(pat)` when `_select_options(pat)` returns zero matches. Unlike `_get_single_key`, `describe_option` does not require a unique match (it describes all hits), but it still errors on zero. The message uses Python's `{pat=}` debug format so it prints as `pat='...'`.
Solutions
- Call `pd.describe_option()` with no argument to list and describe every registered option, then copy the exact key.
- Fix the typo and retry.
- If the option seems gone, check the pandas version/changelog.
Example fix
# before
pd.describe_option('display.max_rowss') # typo -> OptionError
# after
pd.describe_option() # lists all options
pd.describe_option('display.max_rows') Defensive patterns
Strategy: validation
Validate before calling
from pandas._config.config import _select_options
def describe_or_none(pat: str):
if not _select_options(pat):
return None # caller typo; optionally list all via describe_option()
import pandas as pd
return pd.describe_option(pat) Type guard
def has_matching_option(pat: str) -> bool:
import pandas._config.config as c
return len(c._select_options(pat)) > 0 Try / catch
from pandas._config.config import OptionError
try:
pd.describe_option(user_key)
except OptionError:
# fall back to listing all options for the user
pd.describe_option() Prevention
- Validate option patterns against `_select_options` before describing.
- Keep a curated allowlist of option names if they come from user config files.
- Run `pd.describe_option()` once during onboarding to learn valid keys.
When it happens
Trigger: `pd.describe_option('nonexistent.option')` or any pattern matching no registered option.
Common situations: Typo when asking for documentation of an option; asking about an option removed in the installed pandas version.
Related errors
- No such keys(s)
- No such option
- Option ' ' has already been defined as deprecated.
- Pattern matched multiple keys
- You can only set the value of existing options
AI-assisted analysis of pandas-dev/pandas@3b7651241d (2026-08-11).
Data as JSON: /api/errors/5f7337f828cc5e74.
Report an issue: GitHub.
Appendix: source
Thrown at pandas/_config/config.py:335
--------
get_option : Retrieve the value of the specified option.
set_option : Set the value of the specified option or options.
reset_option : Reset one or more options to their default value.
Notes
-----
For all available options, please view the
:ref:`User Guide <options.available>`.
Examples
--------
>>> pd.describe_option("display.max_columns") # doctest: +SKIP
display.max_columns : int
If max_cols is exceeded, switch to truncate view...
"""
keys = _select_options(pat)
if len(keys) == 0:
raise OptionError(f"No such keys(s) for {pat=}")
s = "\n".join([_build_option_description(k) for k in keys])
if _print_desc:
print(s)
return None
return s
def reset_option(pat: str) -> None:
"""
Reset one or more options to their default value.
This method resets the specified pandas option(s) back to their default
values. It allows partial string matching for convenience, but users should
exercise caution to avoid unintended resets due to changes in option names
in future versions.
View on GitHub (pinned to 3b7651241d)