Pandas function option_context() in Python
The Pandas function option_context() is a context manager to temporarily set options in the with statement context.
Syntax
 1 class pandas.option_context(*args)
*args : It specifies an additional arguments to be passed to the function.
option_context() function
 1 import pandas as pd
 2 from pandas import option_context
 3 
 4 df = pd.DataFrame([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]])
 5 
 6 with option_context('display.max_rows', 3, 'display.max_columns', 3):
 7     pass
 8 
 9 print('Program completed execution !!')
Output
 1 Program completed execution !!

Example 2

Example 2
 1 import pandas as pd
 2 from pandas import option_context
 3 
 4 df = pd.DataFrame([[1, 2, 3, 4, 5]])
 5 
 6 with option_context('display.max_rows', 3, 'display.max_columns', 3):
 7     pass
 8 
 9 print('Program completed execution !!')
Output
 1 Program completed execution !!
Privacy Policy
Terms of Service
Disclaimer
Contact us
About us