Skip to main content
`Ctrl`+`K`

# pandas.option_context

pandas.option_context(*args)

  Context manager to temporarily set options in a `with` statement.

  This method allows users to set one or more pandas options temporarily within a controlled block. The previous options’ values are restored once the block is exited. This is useful when making temporary adjustments to pandas’ behavior without affecting the global state.

  Parameters:
    *args str | object | dict

      An even amount of arguments provided in pairs which will be interpreted as (pattern, value) pairs. Alternatively, a single dictionary of {pattern: value} may be provided.

  Returns:
    None

      No return value.

  Yields:
    None

      No yield value.

  See also

  `get_option`

    Retrieve the value of the specified option.

  `set_option`

    Set the value of the specified option.

  `reset_option`

    Reset one or more options to their default value.

  `describe_option`

    Print the description for one or more registered options.

  Notes

  For all available options, please view the User Guide or use `pandas.describe_option()`.

  Examples

      >>> from pandas import option_context
      >>> with option_context("display.max_rows", 10, "display.max_columns", 5):
      ...     pass
      >>> with option_context({"display.max_rows": 10, "display.max_columns": 5}):
      ...     pass