Skip to content
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

ENH: Support dict to pd.set_option for cleaner code #61093

Open
1 of 3 tasks
yasirroni opened this issue Mar 10, 2025 · 0 comments
Open
1 of 3 tasks

ENH: Support dict to pd.set_option for cleaner code #61093

yasirroni opened this issue Mar 10, 2025 · 0 comments
Labels
Enhancement Needs Triage Issue that has not been reviewed by a pandas team member

Comments

@yasirroni
Copy link

yasirroni commented Mar 10, 2025

Feature Type

  • Adding new functionality to pandas

  • Changing existing functionality in pandas

  • Removing existing functionality in pandas

Problem Description

I wish that I could use dict for pd.set_option, just like other packages typically accept dict when there are lots of option. Current pandas style follow what old programming language do, such as MATLAB.

Feature Description

import pandas as pd

options = {
    'display.precision': 2,
    'display.max_columns': 100,
    'styler.format.precision': 2,
}

# like this
pd.set_option(**options)

# or like this:
pd.set_option(options)

Alternative Solutions

Current implementations is:

pd.set_option('display.precision', 2)
pd.set_option('display.max_columns', 100)
pd.set_option('styler.format.precision', 2)

# or

options = {
    'display.precision': 2,
    'display.max_columns': 100,
    'styler.format.precision': 2,
}

for key, value in options.items():
    pd.set_option(key, value)

Additional Context

Because if I write it like this:

pd.set_option(
    'display.precision', 2,
    'display.max_columns', 100,
    'styler.format.precision', 2,
)

An auto formatter like ruff will make it into:

pd.set_option(
    'display.precision',
    2,
    'display.max_columns',
    100,
    'styler.format.precision',
    2,
)
@yasirroni yasirroni added Enhancement Needs Triage Issue that has not been reviewed by a pandas team member labels Mar 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Needs Triage Issue that has not been reviewed by a pandas team member
Projects
None yet
Development

No branches or pull requests

1 participant