pandas-dev/pandas · error · OptionError

No such keys(s) for {pat=}

Error message

No such keys(s) for {pat=}

What it means

Raised by describe_option (config.py:333-335) when _select_options returns no keys for the given pattern. Unlike _get_single_key, describe does not go through _translate_key; it just checks the registered set.

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 71959b8cb9)

Solutions

  1. Call pd.describe_option() with no argument to dump all available keys.
  2. Confirm the key is registered: `import pandas._config.config as cf; cf._registered_options.get(key)`.
  3. Catch OptionError when describing user-supplied option names.

Example fix

# before
pd.describe_option('displya.max_columns')  # No such keys(s) for pat='displya.max_columns'

# after
pd.describe_option('display.max_columns')
Defensive patterns

Strategy: try-catch

Validate before calling

import pandas._config.config as cf
def safe_describe(pat: str) -> str | None:
    if not cf._select_options(pat):
        return None
    return pd.describe_option(pat, _print_desc=False)

Type guard

def has_description(pat: str) -> bool:
    import pandas._config.config as cf
    return bool(cf._select_options(pat))

Try / catch

from pandas.errors import OptionError
try:
    pd.describe_option(user_pat)
except OptionError:
    print('Unknown option; listing all:')
    pd.describe_option()

Prevention

When it happens

Trigger: pd.describe_option('does.not.exist') where the pattern matches zero registered options.

Common situations: Asking for the description of a misspelled or removed option, or a key that exists only under a different namespace.

Related errors


AI-assisted analysis of pandas-dev/pandas@71959b8cb9 (2026-08-07). Data as JSON: /api/errors/5f7337f828cc5e74. Report an issue: GitHub.