-
Notifications
You must be signed in to change notification settings - Fork 99
Fix PandasOptionError import. #99
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
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job, but I think we can use try
except
other than version comparison.
@@ -83,7 +83,12 @@ def __init__(self, *args, **kw): | |||
def getvalue(self, silent=False): | |||
if self._use_pd: | |||
import pandas as pd | |||
from pandas.core.config import OptionError as PandasOptionError | |||
if pd.__version__ < '0.25.0': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could try import pandas.core.config
, if failed, try to import pandas._config.config
. Documents can be added about pandas version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we can do that now.
But it seems not right to handle compatibility issues with exceptions (exceptions are most likely to be something go unexpected).
OptionError
is private in '0.25.0' , but may be published and move to another place afterwards. We can't handle updates directly with ImportError
then.
Any idea?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think try except is a better way. How about just make a modification?
We cannot predict the behavior of pandas in the future, let's fix the current issue first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you given some more reasoning? I really can't understand why try except is preferred in this use case. Importing from pandas.core.config
will sure fail in current and future versions.
And code already committed here did fix the issue.
See also:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please resolve the problem by try except way? thanks.
@@ -83,7 +83,12 @@ def __init__(self, *args, **kw): | |||
def getvalue(self, silent=False): | |||
if self._use_pd: | |||
import pandas as pd | |||
from pandas.core.config import OptionError as PandasOptionError | |||
if pd.__version__ < '0.25.0': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think try except is a better way. How about just make a modification?
We cannot predict the behavior of pandas in the future, let's fix the current issue first.
Sorry to tell you that we have solved the compatible issue in a way that pandas version does not matter. Refer to aliyun-odps-python-sdk/odps/config.py Lines 83 to 91 in ae65e3f
Thank you all the same for your contribution, I will close this PR anyway, welcome to send other PRs. |
pandas.core.config
is no longer available after pandas v0.25See also: