Skip to content

Set pandas options without importing pandas or editing library code #26006

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

Closed
mikepqr opened this issue Apr 5, 2019 · 1 comment
Closed

Set pandas options without importing pandas or editing library code #26006

mikepqr opened this issue Apr 5, 2019 · 1 comment
Labels
Duplicate Report Duplicate issue or pull request

Comments

@mikepqr
Copy link

mikepqr commented Apr 5, 2019

Does pandas provide a way to set its options without importing the module?

I've seen the advice to add something like this to the iPython startup:

import pandas
pandas.options.display.some_pandas_option = 42

this works in iPython and notebooks, but has a couple of problems for my use case:

  1. It doesn't help for scripts run with $ python my_pandas_script.py because python obviously doesn't run the iPython startup stuff.
  2. It leaves pandas in the globals() of the user's iPython session, which I don't want to do (I'm trying to set defaults for a multiuser environment, but I otherwise want things to feel as usual). I know I can add del pandas to that startup script and it will work (i.e. the option will be set correctly for the user if they import pandas), but ...
  3. It just feels ugly (and import pandas is non-zero (but not trivial) startup overhead).

Patching the pandas library itself is not an option in this context (the user is free to upgrade it).

Do I have any other options? e.g. environment variables, dotfiles, etc., etc.?

@WillAyd WillAyd added the Duplicate Report Duplicate issue or pull request label Apr 6, 2019
@WillAyd
Copy link
Member

WillAyd commented Apr 6, 2019

I think you are looking for the feature requested in #4907 so feel free to contribute to that conversation. Closing this as a duplicate

@WillAyd WillAyd closed this as completed Apr 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate Report Duplicate issue or pull request
Projects
None yet
Development

No branches or pull requests

2 participants