Home > Net >  Converting a JSON Dictionary (currently a String) to a Pandas Dataframe
Converting a JSON Dictionary (currently a String) to a Pandas Dataframe

Time:01-06

I am using Python's request library to retrieve data from a web API. When viewing my data using requests.text, it returns a string of a large JSON object, e.g.,

'{"Pennsylvania": {"Sales": [{"date":"2021-12-01", "id": "Metric67", ... '

Naturally, the type of this object is currently a string. What is the best way to cover this string/JSON to a Pandas Dataframe?

CodePudding user response:

You can use the default synatx for API calls:

r=requests.get(YOUR_URL)
res=r.json()

NOTE: r.text returns json as text.

  •  Tags:  
  • Related