我正在尝试使用Python将网络抓取的json数据转换为Panda Dataframe。
from requests import Request, Session
from requests.exceptions import ConnectionError, Timeout, TooManyRedirects
import json
import pandas as pd
url = 'https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest'
parameters = {
'start':'1',
'limit':'5000',
'convert':'USD'
}
headers = {
'Accepts': 'application/json',
'X-CMC_PRO_API_KEY': '8a7f806b-2635-4aed-96f0-5b350bbab953',
}
session = Session()
session.headers.update(headers)
try:
response = session.get(url, params=parameters)
data = json.loads(response.text)
print(data)
except:
print("error")
df = pd.DataFrame(data)
df
ValueError:将字典与非系列混合使用可能会导致顺序不明确。