Skip to content

Commit 1628bfb

Browse files
author
y-p
committed
ENH: expose option_context as a top-level API GH5618
1 parent 36130c0 commit 1628bfb

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

doc/source/basics.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,6 +1457,21 @@ It's also possible to reset multiple options at once (using a regex):
14571457
reset_option("^display")
14581458
14591459
1460+
.. versionadded:: 0.14.0
1461+
1462+
Beginning with v0.14.0 the `option_context` context manager has been exposed through
1463+
the top-level API, allowing you to execute code with given option values. Option values
1464+
are restored automatically when you exit the `with` block:
1465+
1466+
.. ipython:: python
1467+
1468+
with option_context("display.max_rows",10,"display.max_columns", 5):
1469+
print get_option("display.max_rows")
1470+
print get_option("display.max_columns")
1471+
1472+
print get_option("display.max_rows")
1473+
print get_option("display.max_columns")
1474+
14601475
14611476
Console Output Formatting
14621477
-------------------------

doc/source/release.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ Improvements to existing features
6565
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6666

6767
- perf improvements in Series datetime/timedelta binary operations (:issue:`5801`)
68+
- `option_context` context manager now available as top-level API (:issue:`5752`)
6869

6970
Bug Fixes
7071
~~~~~~~~~

pandas/core/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@
3131
import pandas.core.datetools as datetools
3232

3333
from pandas.core.config import (get_option, set_option, reset_option,
34-
describe_option, options)
34+
describe_option, option_context, options)

0 commit comments

Comments
 (0)