Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does pandas.json_normalize(json_results) raise a NotImplementedError?

I have a json variable named json_results and I am running pandas.json_normalize(json_results). It raises the following error:

in _json_normalize
    raise NotImplementedError
NotImplementedError

How can I resolve this?

like image 732
pwlt1998 Avatar asked May 19 '26 17:05

pwlt1998


1 Answers

This error can happen if you pass a JSON string to json_normalize, not an already decoded JSON object.

>>> import json
>>> import pandas as pd

>>> s = '{"hello": "world"}'
>>> pd.json_normalize(s)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../lib/python3.7/site-packages/pandas/io/json/_normalize.py", line 423, in _json_normalize
    raise NotImplementedError
NotImplementedError

>>> d = json.loads(s)
>>> pd.json_normalize(d)
   hello
0  world

If this is the case, use json.loads (or an equivalent Pandas function) first.

like image 75
mkrieger1 Avatar answered May 21 '26 05:05

mkrieger1



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!