-2

I am trying to run a code in Python.

I upload the libraries as follow:

import requests
import json
from datetime import datetime
import pandas as pd
import re
from pandas.io.json import json_normalize

And when I try to extract information from a web site I receive the following error:

C:\Users\Mike\anaconda3\lib\site-packages\ipykernel_launcher.py:1: FutureWarning: pandas.io.json.json_normalize is deprecated, use pandas.json_normalize instead
  """Entry point for launching an IPython kernel.

What am I doing wrong?

halfer
  • 19,824
  • 17
  • 99
  • 186
Messi10
  • 37
  • 1
  • 3
  • 1
    is the warning not clear? just use `pd.json_normalize` as the `from pandas.io.json` variant seems it will be depreciated in future. – Umar.H May 06 '20 at 15:12
  • No, the warning is not clear. The suggestion does not solve my issue. – Messi10 May 07 '20 at 17:06

2 Answers2

7

Pandas now contains the json_normalize functions as pandas.io.json is deprecated.

Replace this:

from pandas.io.json import json_normalize

With this:

from pandas import json_normalize
trussella
  • 71
  • 1
  • 2
1

Delete from pandas.io.json import json_normalize from your imports, and replace json_normalize with pd.json_normalize in your code.

CHRD
  • 1,917
  • 1
  • 15
  • 38
  • Then you need to provide your code or improve the question description. The error you have presented is literally telling you to do this. – CHRD May 07 '20 at 15:16
  • When I do the next step: ```import requests import json from datetime import datetime import pandas as pd import re pd.json_normalize``` I receive the next answer: 'DataFrame'> – Messi10 May 07 '20 at 15:24
  • If I do: ```import requests import json from datetime import datetime import pandas as pd import re import pandas from pd.json_normalize``` I get: Invalid syntax – Messi10 May 07 '20 at 15:25