Skip to content

DOC: cleanup docstring for read_json and fix error in contribution guide #27280

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

Merged
merged 8 commits into from
Jul 17, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions doc/source/development/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ complex changes to the documentation as well.
Some other important things to know about the docs:

* The *pandas* documentation consists of two parts: the docstrings in the code
itself and the docs in this folder ``pandas/doc/``.
itself and the docs in this folder ``doc/``.

The docstrings provide a clear explanation of the usage of the individual
functions, while the documentation in this folder consists of tutorial-like
Expand Down Expand Up @@ -404,11 +404,11 @@ Building the documentation
~~~~~~~~~~~~~~~~~~~~~~~~~~

So how do you build the docs? Navigate to your local
``pandas/doc/`` directory in the console and run::
``doc/`` directory in the console and run::

python make.py html

Then you can find the HTML output in the folder ``pandas/doc/build/html/``.
Then you can find the HTML output in the folder ``doc/build/html/``.

The first time you build the docs, it will take quite a while because it has to run
all the code examples and build all the generated docstring pages. In subsequent
Expand Down Expand Up @@ -448,7 +448,7 @@ You can also specify to use multiple cores to speed up the documentation build::
Open the following file in a web browser to see the full documentation you
just built::

pandas/docs/build/html/index.html
doc/build/html/index.html

And you'll have the satisfaction of seeing your new and improved documentation!

Expand Down
39 changes: 22 additions & 17 deletions pandas/io/json/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,9 @@ def read_json(
path_or_buf : a valid JSON string or file-like, default: None
The string could be a URL. Valid URL schemes include http, ftp, s3,
gcs, and file. For file URLs, a host is expected. For instance, a local
file could be ``file://localhost/path/to/table.json``
file could be ``file://localhost/path/to/table.json``.

orient : string,
orient : str,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
orient : str,
orient : str

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the preferred change, according to the docs, would be str, optional. However, the (many) other parameters in the docstring just put the default value. I will make it read str, default None for consistency's sake. I'll leave trudging through the function code and conforming the other parameter descriptions to the preferred style for another day . . .

Indication of expected JSON string format.
Compatible JSON strings can be produced by ``to_json()`` with a
corresponding orient value.
Expand Down Expand Up @@ -394,7 +394,8 @@ def read_json(
'table' as an allowed value for the ``orient`` argument

typ : type of object to recover (series or frame), default 'frame'
dtype : boolean or dict, default None

dtype : bool or dict, default None
If True, infer dtypes; if a dict of column to dtype, then use those;
if False, then don't infer dtypes at all, applies only to the data.

Expand All @@ -404,7 +405,7 @@ def read_json(

Not applicable for ``orient='table'``.

convert_axes : boolean, default None
convert_axes : bool, default None
Try to convert the axes to the proper dtypes.

For all ``orient`` values except ``'table'``, default is True.
Expand All @@ -413,9 +414,9 @@ def read_json(

Not applicable for ``orient='table'``.

convert_dates : boolean, default True
List of columns to parse for dates; If True, then try to parse
datelike columns default is True; a column label is datelike if
convert_dates : bool or list, default True
List of columns to parse for dates. If True, then try to parse
datelike columns. A column label is datelike if

* it ends with ``'_at'``,

Expand All @@ -425,34 +426,38 @@ def read_json(

* it is ``'modified'``, or

* it is ``'date'``
* it is ``'date'``.

keep_default_dates : bool, default True
If parsing dates, then parse the default datelike columns.

keep_default_dates : boolean, default True
If parsing dates, then parse the default datelike columns
numpy : boolean, default False
numpy : bool, default False
Direct decoding to numpy arrays. Supports numeric data only, but
non-numeric column and index labels are supported. Note also that the
JSON ordering MUST be the same for each term if numpy=True.
precise_float : boolean, default False

precise_float : bool, default False
Set to enable usage of higher precision (strtod) function when
decoding string to double values. Default (False) is to use fast but
less precise builtin functionality
date_unit : string, default None
less precise builtin functionality.

date_unit : str, default None
The timestamp unit to detect if converting dates. The default behaviour
is to try and detect the correct precision, but if this is not desired
then pass one of 's', 'ms', 'us' or 'ns' to force parsing only seconds,
milliseconds, microseconds or nanoseconds respectively.

encoding : str, default is 'utf-8'
The encoding to use to decode py3 bytes.

.. versionadded:: 0.19.0

lines : boolean, default False
lines : bool, default False
Read the file as a json object per line.

.. versionadded:: 0.19.0

chunksize : integer, default None
chunksize : int, default None
Return JsonReader object for iteration.
See the `line-delimited json docs
<http://pandas.pydata.org/pandas-docs/stable/user_guide/io.html#line-delimited-json>`_
Expand All @@ -473,7 +478,7 @@ def read_json(

Returns
-------
result : Series or DataFrame, depending on the value of `typ`.
Series or DataFrame, depending on the value of `typ`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our standard is to leave just the type Series or DataFrame in this line, and in the next indented to add any explanation. If you can update here, that would be great.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do.


See Also
--------
Expand Down