1.2 Getting and Setting Options

As described above, get_option() and set_option() are available from the pandas namespace. To change an option, call set_option('option regex', new_value)

In [1]: pd.get_option('mode.sim_interactive')
Out[1]: False

In [2]: pd.set_option('mode.sim_interactive', True)

In [3]: pd.get_option('mode.sim_interactive')
Out[3]: True

Note: that the option ‘mode.sim_interactive’ is mostly used for debugging purposes.

All options also have a default value, and you can use reset_option to do just that:

In [4]: pd.get_option("display.max_rows")
Out[4]: 60

In [5]: pd.set_option("display.max_rows",999)

In [6]: pd.get_option("display.max_rows")
Out[6]: 999

In [7]: pd.reset_option("display.max_rows")

In [8]: pd.get_option("display.max_rows")
Out[8]: 60

It’s also possible to reset multiple options at once (using a regex):

In [9]: pd.reset_option("^display")
height has been deprecated.

line_width has been deprecated, use display.width instead (currently both are
identical)

option_context context manager has been exposed through the top-level API, allowing you to execute code with given option values. Option values are restored automatically when you exit the with block:

In [10]: with pd.option_context("display.max_rows",10,"display.max_columns", 5):
   ....:      print(pd.get_option("display.max_rows"))
   ....:      print(pd.get_option("display.max_columns"))
   ....: 
10
5

In [11]: print(pd.get_option("display.max_rows"))
60

In [12]: print(pd.get_option("display.max_columns"))
20