pandas docs json_normalize example
State: closed

- [x] closes #36184 
- [x] Inserted " pandas. " preceding the json_normalize() method in the example cells where it was missing.
Documentation Location : [https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.json_normalize.html](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.json_normalize.html)

Labels:
name: Docs
name: IO JSON
description: read_json, to_json, json_normalize

Comments:
thanks @nzare 
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?
hmm yes we should change to use pd

if u would like to do a PR would be great
> 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)
good point @dsaxton 
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?
> > 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](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.json_normalize.html). 

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]
``` 

> 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](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.json_normalize.html).

The link is for json_normalize. json_optimize doesn't exist:
```python
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'
```
> > 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](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.json_normalize.html).
> 
> The link is for json_normalize. json_optimize doesn't exist:
> 
> ```python
> 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.