0

I want to load the data from an API into a pandas data frame. How may I do that? The following is my code snippet:

import requests
import json
response_API = requests.get('https://data.spiceai.io/eth/v0.1/gasfees?period=1d')
#print(response_API.status_code)
data = response_API.text
parse_json = json.loads(data)
1
  • You should start by installing/importing pandas and then building your dataframe from the list of dictionaries. You also can use response_API.json() so you don't have to manually convert it Commented May 11, 2022 at 9:36

1 Answer 1

1

Almost there, the json is clean you can directly input it to a dataframe :

response_API = requests.get('https://data.spiceai.io/eth/v0.1/gasfees?period=1d')
data = response_API.json()
df = pd.DataFrame(data)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.