簡體   English   中英

read_json 使用 pandas.read_json 返回空數據框

[英]read_json returns empty dataframe using pandas.read_json

我正在運行此代碼,但 api 停止發送賭注值,我如何將“vazio”數據框化以報廢里面的值?

vazio='https://api-v2.blaze.com/roulette_games/current'
    
urlData = requests.get(vazio).content
rodadaatual = pd.read_json(io.StringIO(urlData.decode('utf-8')))

輸出

Empty DataFrame
Columns: [id, color, roll, created_at, updated_at, status, total_red_eur_bet, total_red_bets_placed, total_white_eur_bet, total_white_bets_placed, total_black_eur_bet, total_black_bets_placed, bets]
Index: []

您需要以有效的 json 列表格式提供您讀取的數據。 然后就可以使用pandas.read_json來讀取 json 數據了

urlData = '[' + urlData.decode('utf-8') + ']'
pd.read_json(urlData)

輸出 :

這為我們提供了所需的數據框

           id  color  roll  ... total_black_eur_bet total_black_bets_placed bets
0  BylLAX00rG    NaN   NaN  ...                   0                       0   []

[1 rows x 13 columns]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM