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

pd.option_context without 'with' changes option values #8514

Closed
jorisvandenbossche opened this issue Oct 8, 2014 · 3 comments · Fixed by #8925
Closed

pd.option_context without 'with' changes option values #8514

jorisvandenbossche opened this issue Oct 8, 2014 · 3 comments · Fixed by #8925
Milestone

Comments

@jorisvandenbossche
Copy link
Member

Just wondering if this is a bug, from http://stackoverflow.com/questions/26246864/restoring-the-default-display-context-in-pandas

If you use pd.option_context accidentally without with, this changes the default option values.

@jorisvandenbossche jorisvandenbossche changed the title pd.option_context without 'with' pd.option_context without 'with' changes option values Oct 8, 2014
@jorisvandenbossche
Copy link
Member Author

BTW, using reset_options generates deprecation warnings:

In [22]: pd.reset_option('all')
height has been deprecated.

line_width has been deprecated, use display.width instead (currently both are identical)

These should be suppressed here I think.

@jorisvandenbossche
Copy link
Member Author

Should the option setting (https://github.com/pydata/pandas/blob/master/pandas/core/config.py#L394) happen in the __enter__ instead of __init__?

@jreback
Copy link
Contributor

jreback commented Oct 8, 2014

yep it looks like it should be happening in __enter__, then I suppose you could do:

i = pd.option_context(.......)
j = pd.option_context(.....different ones...)

with i:
    do something

with j:
    do something else

@jreback jreback added this to the 0.15.1 milestone Oct 9, 2014
@jreback jreback modified the milestones: 0.16.0, 0.15.2 Nov 24, 2014
hkleynhans added a commit to hkleynhans/pandas that referenced this issue Nov 29, 2014
Option context no longer overrides options when used outside a `with`
statement.

Added test TestConfig.test_option_config_scope

Closes pandas-dev#8514
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants