Skip to main content
`Ctrl`+`K`

# pandas.set_option

pandas.set_option(*args)

  Set the value of the specified option or options.

  This method allows fine-grained control over the behavior and display settings of pandas. Options affect various functionalities such as output formatting, display limits, and operational behavior. Settings can be modified at runtime without requiring changes to global configurations or environment variables.

  Parameters:
    *args str | object | dict

      Arguments provided in pairs, which will be interpreted as (pattern, value), or as a single dictionary containing multiple option-value pairs. pattern: str Regexp which should match a single option value: object New value of option

      Warning

      Partial pattern matches are supported for convenience, but unless you use the full option name (e.g. x.y.z.option_name), your code may break in future versions if new options with similar names are introduced.

  Returns:
    None

      No return value.

  Raises:
    ValueError if odd numbers of non-keyword arguments are provided
    TypeError if keyword arguments are provided
    OptionError if no such option exists

  See also

  `get_option`

    Retrieve 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.

  `option_context`

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

  Notes

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

  Examples

  Option-Value Pair Input:

      >>> pd.set_option("display.max_columns", 4)
      >>> df = pd.DataFrame([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]])
      >>> df
      0  1  ...  3   4
      0  1  2  ...  4   5
      1  6  7  ...  9  10
      [2 rows x 5 columns]
      >>> pd.reset_option("display.max_columns")

  Dictionary Input:

      >>> pd.set_option({"display.max_columns": 4, "display.precision": 1})
      >>> df = pd.DataFrame([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]])
      >>> df
      0  1  ...  3   4
      0  1  2  ...  4   5
      1  6  7  ...  9  10
      [2 rows x 5 columns]
      >>> pd.reset_option("display.max_columns")
      >>> pd.reset_option("display.precision")