Acccending False 無法給我最大數字中的大多數資料。
import pandas as pd
from binance.client import Client
client = Client()
ticker_info = pd.DataFrame(client.get_ticker())
busd_info = ticker_info[ticker_info.symbol.str.contains('USDT')]
busd_info = busd_info.sort_values(by='priceChangePercent', ascending=False)
# busd_info = busd_info.priceChangePercent.max()
print(busd_info.head(60))
print(busd_info)

uj5u.com熱心網友回復:
您可以嘗試檢查您的資料型別嗎?
print(busd_info.dtypes)
如果不是你想要的型別,比如你priceChangePercent應該是float型別,那么你可以在排序前先轉換它。
# Convert to correct type
busd_info.priceChangePercent = bush_info.priceChangePercent.astype(float)
# Sorting
busd_info = busd_info.sort_values(by='priceChangePercent', ascending=False)
print(busd_info)
uj5u.com熱心網友回復:
如果測驗dtype:
print (busd_info.priceChangePercent.dtype)
object
這意味著沒有數值按字典順??序像字串那樣排序。
對于轉換為數字,如果不存在數字值到s ,則to_numeric使用for convert:errors='coerce'NaN
busd_info.priceChangePercent = pd.to_numeric(bush_info.priceChangePercent, errors='coerce')
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/480597.html
