I have found myself in cases where I accidentally run:
pd.option_context('display.max_columns', None,
'display.max_rows', None,
'display.width', None,
'display.max_colwidth', 0)
without the with
clause. Unfortunately, that changes my default printing options for all my print
statements.
My question is: How can I restore the default context
?
Calling pd.option_context()
without arguments doesn't work, I get:
ValueError: Need to invoke asoption_context(pat, val, [(pat, val), ...)).
Use pandas. reset_option("all") to reset all display options.
set_option(param,value) Using set_option(), we can change the default number of rows to be displayed. import pandas as pd pd. set_option("display.max_rows",80) print pd. get_option("display.max_rows") Its output is as follows − 80.
CTRL + Z is the only thing that I can think of.
Set value of display. max_rows to None and pass it to set_option and this will display all rows from the data frame.
You can use pd.reset_option
to reset one option or you can use a regex to reset more than one at the same time. In your case to reset all options starting with display
you can do:
pd.reset_option('^display.', silent=True)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With