Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

ENH: Added dict support for pd.set_option #61151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
May 29, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added example to set_option description
  • Loading branch information
arthurlw committed Mar 22, 2025
commit 4794cfcb63a9fa2f1c996fc2b508f74e8e6f20bb
18 changes: 16 additions & 2 deletions 18 pandas/_config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ def set_option(*args) -> None:
Parameters
----------
*args : str | object | dict
Arguments provided in pairs, which will be interpreted as (pattern, value)
pairs, or as a single dictionary containing multiple option-value pairs.
Arguments provided in a pair, 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
Expand Down Expand Up @@ -239,6 +239,8 @@ def set_option(*args) -> None:

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
Expand All @@ -247,6 +249,18 @@ def set_option(*args) -> None:
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")
"""
# Handle dictionary input
if len(args) == 1 and isinstance(args[0], dict):
Expand Down
3 changes: 2 additions & 1 deletion 3 pandas/tests/config/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ def test_set_option_multiple(self):
assert cf.get_option("b.c") == "hullo"
assert cf.get_option("b.b") is None

# Expect the deprecation warning
with tm.assert_produces_warning(
FutureWarning,
match="Setting multiple options using multiple arguments is deprecated",
Expand All @@ -201,6 +200,8 @@ def test_set_option_multiple(self):
assert cf.get_option("b.b") == 10.0

def test_set_option_dict(self):
# GH 61093

cf.register_option("a", 1, "doc")
arthurlw marked this conversation as resolved.
Show resolved Hide resolved
cf.register_option("b.c", "hullo", "doc2")
cf.register_option("b.b", None, "doc2")
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.