pandas 等级警告:Polyfit可能调节不良

ifmq2ha2  于 2023-04-04  发布在  其他
关注(0)|答案(2)|浏览(244)

我正在尝试使用pandas查找btc交易数据(分钟数据)的滚动价格斜率。当我运行脚本时,弹出以下错误/警告
sys:1:Rank警告:Polyfit可能调节不良
我从中获取数据的url是https://data.binance.vision/data/spot/monthly/klines/BTCUSDT/1m/BTCUSDT-1m-2021-01.zip
滚动价格斜率计算如下(时间段为30):

result['date_ordinal'] = pd.to_datetime(result['Open Time']).map(dt.datetime.toordinal)

for index, data in result.iterrows():

    price_slope = np.polyfit(result['date_ordinal'][index-time_period:index+1],result['Close'][index-time_period:index+1],1)
2nc8po8w

2nc8po8w1#

有太多的数据,或者你的功能的程度很高,或者等等。
如果你不能解决这个问题,你可以通过以下方法来避免:
导入警告

4szc88ey

4szc88ey2#

要禁用警告,请执行以下操作:

import warnings    
warnings.simplefilter('ignore', np.RankWarning)

https://numpy.org/devdocs/reference/generated/numpy.polyfit.html找到的

相关问题