Skip to content

Conversation

nzare
Copy link
Contributor

@nzare nzare commented Sep 7, 2020

@dsaxton dsaxton added the Docs label Sep 7, 2020
Copy link
Contributor

@dsaxton dsaxton left a comment

Choose a reason for hiding this comment

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

Thanks @nzare for the PR

@jreback jreback added this to the 1.2 milestone Sep 8, 2020
@jreback jreback added the IO JSON read_json, to_json, json_normalize label Sep 8, 2020
@jreback jreback merged commit 19f0a9f into pandas-dev:master Sep 8, 2020
@jreback
Copy link
Contributor

jreback commented Sep 8, 2020

thanks @nzare

@ylin00
Copy link
Contributor

ylin00 commented Sep 8, 2020

Hi @nzare and @jreback ,

I got an unexpected error trying to validate the updated docstring:

./scripts/validate_docstrings.py pandas.json_optimize
Traceback (most recent call last):
  File "./scripts/validate_docstrings.py", line 435, in <module>
    args.ignore_deprecated,
  File "./scripts/validate_docstrings.py", line 380, in main
    print_validate_one_results(func_name)
  File "./scripts/validate_docstrings.py", line 350, in print_validate_one_results
    result = pandas_validate(func_name)
  File "./scripts/validate_docstrings.py", line 213, in pandas_validate
    doc = PandasDocstring(func_name)
  File "/opt/conda/lib/python3.7/site-packages/numpydoc/validate.py", line 128, in __init__
    obj = self._load_obj(name)
  File "/opt/conda/lib/python3.7/site-packages/numpydoc/validate.py", line 167, in _load_obj
    obj = getattr(obj, part)
  File "/workspaces/pandas-yl/pandas/__init__.py", line 257, in __getattr__
    raise AttributeError(f"module 'pandas' has no attribute '{name}'")
AttributeError: module 'pandas' has no attribute 'json_optimize'

I believe changing pandas. to pd. should fix this?

@jreback
Copy link
Contributor

jreback commented Sep 8, 2020

hmm yes we should change to use pd

if u would like to do a PR would be great

@dsaxton
Copy link
Contributor

dsaxton commented Sep 8, 2020

Hi @nzare and @jreback ,

I got an unexpected error trying to validate the updated docstring:

./scripts/validate_docstrings.py pandas.json_optimize
Traceback (most recent call last):
  File "./scripts/validate_docstrings.py", line 435, in <module>
    args.ignore_deprecated,
  File "./scripts/validate_docstrings.py", line 380, in main
    print_validate_one_results(func_name)
  File "./scripts/validate_docstrings.py", line 350, in print_validate_one_results
    result = pandas_validate(func_name)
  File "./scripts/validate_docstrings.py", line 213, in pandas_validate
    doc = PandasDocstring(func_name)
  File "/opt/conda/lib/python3.7/site-packages/numpydoc/validate.py", line 128, in __init__
    obj = self._load_obj(name)
  File "/opt/conda/lib/python3.7/site-packages/numpydoc/validate.py", line 167, in _load_obj
    obj = getattr(obj, part)
  File "/workspaces/pandas-yl/pandas/__init__.py", line 257, in __getattr__
    raise AttributeError(f"module 'pandas' has no attribute '{name}'")
AttributeError: module 'pandas' has no attribute 'json_optimize'

I believe changing pandas. to pd. should fix this?

@ylin00 I think your command is not correct, there is no function pandas.json_optimize (that's what's causing the error, not a problem with a docstring)

@jreback
Copy link
Contributor

jreback commented Sep 8, 2020

good point @dsaxton

@dsaxton
Copy link
Contributor

dsaxton commented Sep 8, 2020

Although if you run ./scripts/validate_docstrings.py pandas.io.json._normalize._json_normalize it looks like there is an issue. May need an import of pandas at the top?

@ylin00
Copy link
Contributor

ylin00 commented Sep 8, 2020

Hi @nzare and @jreback ,
I got an unexpected error trying to validate the updated docstring:

./scripts/validate_docstrings.py pandas.json_optimize
Traceback (most recent call last):
  File "./scripts/validate_docstrings.py", line 435, in <module>
    args.ignore_deprecated,
  File "./scripts/validate_docstrings.py", line 380, in main
    print_validate_one_results(func_name)
  File "./scripts/validate_docstrings.py", line 350, in print_validate_one_results
    result = pandas_validate(func_name)
  File "./scripts/validate_docstrings.py", line 213, in pandas_validate
    doc = PandasDocstring(func_name)
  File "/opt/conda/lib/python3.7/site-packages/numpydoc/validate.py", line 128, in __init__
    obj = self._load_obj(name)
  File "/opt/conda/lib/python3.7/site-packages/numpydoc/validate.py", line 167, in _load_obj
    obj = getattr(obj, part)
  File "/workspaces/pandas-yl/pandas/__init__.py", line 257, in __getattr__
    raise AttributeError(f"module 'pandas' has no attribute '{name}'")
AttributeError: module 'pandas' has no attribute 'json_optimize'

I believe changing pandas. to pd. should fix this?

@ylin00 I think your command is not correct, there is no function pandas.json_optimize (that's what's causing the error, not a problem with a docstring)

I think you are referring to previous version of pandas. Or maybe I misunderstood the term 'function', but I did find pandas.json_optimize here.

And I think pandas.io.json.json_normalize is deprecated.

pd.io.json.json_normalize({})
__main__:1: FutureWarning: pandas.io.json.json_normalize is deprecated, use pandas.json_normalize instead
Empty DataFrame
Columns: []
Index: [0]

@dsaxton
Copy link
Contributor

dsaxton commented Sep 8, 2020

I think you are referring to previous version of pandas. Or maybe I misunderstood the term 'function', but I did find pandas.json_optimize here.

The link is for json_normalize. json_optimize doesn't exist:

In [1]: import pandas as pd

In [2]: pd.json_optimize
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-2-eb7fafd03573> in <module>
----> 1 pd.json_optimize

~/pandas/pandas/__init__.py in __getattr__(name)
    255         return _SparseArray
    256
--> 257     raise AttributeError(f"module 'pandas' has no attribute '{name}'")
    258
    259

AttributeError: module 'pandas' has no attribute 'json_optimize'

In [3]: pd.__version__
Out[3]: '1.2.0.dev0+298.g19f0a9fa0'

@ylin00
Copy link
Contributor

ylin00 commented Sep 8, 2020

I think you are referring to previous version of pandas. Or maybe I misunderstood the term 'function', but I did find pandas.json_optimize here.

The link is for json_normalize. json_optimize doesn't exist:

In [1]: import pandas as pd

In [2]: pd.json_optimize
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-2-eb7fafd03573> in <module>
----> 1 pd.json_optimize

~/pandas/pandas/__init__.py in __getattr__(name)
    255         return _SparseArray
    256
--> 257     raise AttributeError(f"module 'pandas' has no attribute '{name}'")
    258
    259

AttributeError: module 'pandas' has no attribute 'json_optimize'

In [3]: pd.__version__
Out[3]: '1.2.0.dev0+298.g19f0a9fa0'

You are right. I was mistyping the word. I filed PR #36207 for the correct one.

jbrockmendel pushed a commit to jbrockmendel/pandas that referenced this pull request Sep 8, 2020
Co-authored-by: Nidhi Zare <nidhizare2685@gmail.com>
kesmit13 pushed a commit to kesmit13/pandas that referenced this pull request Nov 2, 2020
Co-authored-by: Nidhi Zare <nidhizare2685@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Docs IO JSON read_json, to_json, json_normalize

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DOC: Insert "pandas" into json_normalize examples

4 participants