-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Fix hard-coded pandas version to infer the current #24509
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
>>> import pandas as pd >>> pd.__version__ '0.23.4' >>> df = pd.DataFrame({'A': [1,2], 'B': ['a','b']}) >>> # BEFORE >>> pd.io.json.build_table_schema(df, index=0)['pandas_version'] '0.20.0' >>> # AFTER >>> pd.io.json.build_table_schema(df, index=0)['pandas_version'] '0.23.4'
Codecov Report
@@ Coverage Diff @@
## master #24509 +/- ##
==========================================
+ Coverage 31.89% 31.9% +<.01%
==========================================
Files 166 166
Lines 52421 52422 +1
==========================================
+ Hits 16722 16723 +1
Misses 35699 35699
Continue to review full report at Codecov.
|
1 similar comment
Codecov Report
@@ Coverage Diff @@
## master #24509 +/- ##
==========================================
+ Coverage 31.89% 31.9% +<.01%
==========================================
Files 166 166
Lines 52421 52422 +1
==========================================
+ Hits 16722 16723 +1
Misses 35699 35699
Continue to review full report at Codecov.
|
@@ -223,7 +224,7 @@ def build_table_schema(data, index=True, primary_key=None, version=True): | |||
{'name': 'A', 'type': 'integer'}, | |||
{'name': 'B', 'type': 'string'}, | |||
{'name': 'C', 'type': 'datetime'}], | |||
'pandas_version': '0.20.0', | |||
'pandas_version': '0.23.4', |
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.
This should also be dynamic if we change the other one.
You can use the Substitution
decorator to do it.
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.
Would it be a good idea to use f-string instead of Substitution
?
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.
Or if you know of a reference for Substitution
decorator, I'm not familar with it.
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 can't use f-strings, as we support python 2.7 and 3.5. I'd use Substitution
for consistency with the rest of docstrings (and I'm not sure if you can call .format()
on a docstring)
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.
just do a grep in the code, it's a decorator implemented in pandas itself
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.
.format()
is actually possible in docstring. Python 2.7 is gonna die soon :)
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.
Actually, not..format()
does not seem to work with docstring
you will also have to fix the imports, |
you can leave all the changes that isort does, but as far as |
I don't think we want to do this. I think the intent was to increment the version whenever we make an API breaking change to the schema. You might want to look back at the PR when JSON table schema writing was originally added to verify. |
In retrospect, using the pandas version at the time of the API break is not the clearest thing in the world. |
Search for "pandas_version" in http://pandas-docs.github.io/pandas-docs-travis/io.html#table-schema. Again, not the clearest ("each revision" of what?) In my mind, it was each revision of the spec. |
I see, thanks. I will go ahead and close the PR. |
Fix hard-coded pandas version to infer the current version in
pd.io.json.build_table_schema
output.