接受错误,无法从最大的号码给我大部分的数据。
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)

发布于 2022-05-23 07:23:43
你能试着检查一下你的数据类型吗?
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)发布于 2022-05-23 07:26:46
中频测试dtype
print (busd_info.priceChangePercent.dtype)
object这意味着没有像字符串一样按字典顺序排序的数值。
要转换为数值,如果不存在数值,请使用to_numeric和errors='coerce'进行转换,转换为NaN:
busd_info.priceChangePercent = pd.to_numeric(bush_info.priceChangePercent, errors='coerce')https://stackoverflow.com/questions/72344505
复制相似问题