import pyfolio as pf
pf.create_full_tear_sheet(returns)
报错内容
Users\HP\pyfolio\timeseries.py:724: FutureWarning: The default dtype for empty Series will be 'object' instead of 'float64' in a future version. Specify a dtype explicitly to silence this warning.
stats = pd.Series()
请问,如何解决?
首先这不是报错而是警告,是不影响你的程序运行的,意思是未来的版本中 空Series 的默认类型将改为object,而不是float64了:
python - 弃用警告 : The default dtype for empty Series will be 'object' instead of 'float64' in a future version warning - IT工具网
如果想消除警告,可以试试:
stats = pd.Series([],dtype=pd.StringDtype())