-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
DOC: update the to_json() docstring #20149
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
DOC: update the to_json() docstring #20149
Conversation
Fixes validation errors and adds an example for each orientation
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.
Thanks for the PR!
Added an inline comment. And two additional ones:
- In the See Also section, can you change
pd.read_json
topandas.read_json
? - In the "Parameters" section, in the description of the 'orient', in the bullet point "The format of the JSON string", can you quote the options? (so eg
- 'split': ...
instead of- split: ...
), to make it clear it are strings that needs to be passed.
pandas/core/generic.py
Outdated
@@ -1665,8 +1665,9 @@ def to_json(self, path_or_buf=None, orient=None, date_format=None, | |||
Parameters | |||
---------- | |||
path_or_buf : the path or buffer to write the result string |
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.
The "the path or buffer to write the result string" is actually the explanation, so should go on the next line. On this line comes the type description, you can take a look at eg DataFrame.to_csv how this is typically explained.
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.
Cheers
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.
@jorisvandenbossche pandas.read_json
also gives an error I'm afraid, but it is consistent with the other docstrings
pandas/core/generic.py
Outdated
@@ -1665,8 +1665,9 @@ def to_json(self, path_or_buf=None, orient=None, date_format=None, | |||
Parameters | |||
---------- | |||
path_or_buf : the path or buffer to write the result string |
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.
Cheers
Adds quotes in parameters and updates path_or_buf to match to_csv
Codecov Report
@@ Coverage Diff @@
## master #20149 +/- ##
==========================================
+ Coverage 91.72% 91.76% +0.03%
==========================================
Files 150 150
Lines 49156 49148 -8
==========================================
+ Hits 45090 45099 +9
+ Misses 4066 4049 -17
Continue to review full report at Codecov.
|
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.
added a small edit of some quotes, and removed the return statement (was already there, but actually wrong)
@robmarkcole Thanks for the PR! |
Fixes validation errors and adds an example for each orientation.
scripts/validate_docstrings.py <your-function-or-method>
git diff upstream/master -u -- "*.py" | flake8 --diff
python doc/make.py --single <your-function-or-method>
I'm not able to make this pass.