qlib icon indicating copy to clipboard operation
qlib copied to clipboard

下载好数据后,运行workflow_by_code.py报错

Open nnbh2020 opened this issue 2 years ago • 1 comments

PS D:\code\qlib> & D:/ProgramData/Anaconda3/python.exe d:/code/qlib/examples/workflow_by_code.py [13268:MainThread](2023-10-26 10:44:43,251) INFO - qlib.Initialization - [config.py:416] - default_conf: client. [13268:MainThread](2023-10-26 10:44:43,253) INFO - qlib.Initialization - [init.py:74] - qlib successfully initialized based on client settings. [13268:MainThread](2023-10-26 10:44:43,254) INFO - qlib.Initialization - [init.py:76] - data_path={'__DEFAULT_FREQ': WindowsPath('C:/Users/Administrator/.qlib/qlib_data/cn_data')} [13268:MainThread](2023-10-26 10:45:00,193) ERROR - qlib.workflow - [utils.py:41] - An exception has been raised[TypeError: cannot do slice indexing on Index with these indexers [1892] of type int]. File "d:/code/qlib/examples/workflow_by_code.py", line 26, in dataset = init_instance_by_config(CSI300_GBDT_TASK["dataset"])

这个错误提示表明在尝试对一个整数进行切片索引操作时出现了问题。切片索引通常用于对序列类型的数据结构(如列表、元组或pandas的Series)进行选择或提取子序列的操作。然而,错误提示中提到的索引是一个整数(1892),而不是一个序列类型,因此无法进行切片操作。

这个错误可能是由于在代码中使用了一个整数类型的索引来访问一个数据结构,而该数据结构并不支持切片操作。为了解决这个问题,我们需要检查代码中使用索引的地方,确保使用正确的数据结构或方法来进行操作。

nnbh2020 avatar Oct 26 '23 02:10 nnbh2020

After my tests I didn't find the same problem, I suggest you to create a fresh virtual environment with conda, then install qlib and try to run workflow_by_code.py again.

SunsetWolf avatar Nov 24 '23 07:11 SunsetWolf