pandas-dev/pandas · error · ValueError
Value must be one of {pp_values}
Error message
Value must be one of {pp_values} What it means
Raised by the is_one_of_factory validator, which restricts a config option to a fixed list of legal values (optionally plus callables). When set_option() is called with a value not in the legal set, it raises ValueError listing the allowed values. The shipped usage is io/pytables.py:235 registering the format option with legal values ['fixed', 'table', None].
Source
Thrown at pandas/_config/config.py:902
if not isinstance(x, _type):
raise ValueError(f"Value must be an instance of {type_repr}")
return inner
def is_one_of_factory(legal_values: Sequence) -> Callable[[Any], None]:
callables = [c for c in legal_values if callable(c)]
legal_values = [c for c in legal_values if not callable(c)]
def inner(x: object) -> None:
if x not in legal_values:
if not any(c(x) for c in callables):
uvals = [str(lval) for lval in legal_values]
pp_values = "|".join(uvals)
msg = f"Value must be one of {pp_values}"
if len(callables):
msg += " or a callable"
raise ValueError(msg)
return inner
def is_nonnegative_int(value: object) -> None:
"""
Verify that value is None or a positive int.
Parameters
----------
value : None or int
The `value` to be checked.
Raises
------
ValueError
When the value is not None or is a negative integer
"""View on GitHub (pinned to 71959b8cb9)
Solutions
- Use one of the legal values listed in the error message — for HDF format that is 'fixed', 'table', or None.
- Run pd.describe_option('io.hdf.table.format') to see the allowed values before setting.
- If writing your own option, re-read the legal_values list you passed to is_one_of_factory.
Example fix
# before
pd.set_option('io.hdf.table.format', 'csv')
# after
pd.set_option('io.hdf.table.format', 'table') Defensive patterns
Strategy: validation
Validate before calling
legal = ['fixed', 'table', None]
value = get_format()
if value not in legal:
raise ValueError(f'format must be one of {legal}, got {value!r}')
pd.set_option('io.hdf.table.format', value) Prevention
- Keep the legal-values list next to the set_option call as a constant.
- Validate config-file inputs against the allowed set before applying.
- Use pd.describe_option(key) to confirm accepted values.
When it happens
Trigger: Calling pd.set_option('io.hdf.table.format', value) with anything other than 'fixed', 'table', or None triggers the check (the HDF5 format option). Registering a custom option with validator=cf.is_one_of_factory([...]) and setting an out-of-set value does the same.
Common situations: Typing a format string (e.g. 'csv' or 'parquet') that isn't a valid HDF format; passing a value from an unvalidated config file; confusion about whether None is a valid sentinel.
Related errors
- Value must be an instance of {type_repr}
- Value must be a nonnegative integer or None
- Value must be a callable
- No such keys(s): {pat!r}
- Must provide an even number of non-keyword arguments
AI-assisted analysis of pandas-dev/pandas@71959b8cb9 (2026-08-07).
Data as JSON: /api/errors/05dc41ffdbfd83c9.
Report an issue: GitHub.