Skip to content

json_normalize throws AttributeError when calling with array of values #21608

Closed
@vuminhle

Description

@vuminhle

Code Sample, a copy-pastable example if possible

xref #21605

from pandas.io.json import json_normalize

json_normalize([1, 2])

Problem description

The above code throws AttributeError:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python36\lib\site-packages\pandas\io\json\normalize.py", line 193, in json_normalize
    for x in compat.itervalues(y)] for y in data]):
  File "C:\Python36\lib\site-packages\pandas\io\json\normalize.py", line 193, in <listcomp>
    for x in compat.itervalues(y)] for y in data]):
  File "C:\Python36\lib\site-packages\pandas\compat\__init__.py", line 211, in itervalues
    return iter(obj.values(**kw))
AttributeError: 'int' object has no attribute 'values'

Expected Output

0
0 1
1 2

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.6.4.final.0
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 62 Stepping 4, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
LOCALE: None.None

pandas: 0.23.1
pytest: 3.6.1
pip: 10.0.1
setuptools: 28.8.0
Cython: None
numpy: 1.14.2
scipy: None
pyarrow: None
xarray: None
IPython: 6.3.1
sphinx: None
patsy: None
dateutil: 2.7.2
pytz: 2018.4
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: 4.6.0
html5lib: 1.0.1
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementError ReportingIncorrect or improved errors from pandasIO JSONread_json, to_json, json_normalizeNeeds DiscussionRequires discussion from core team before further action

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions