qlib icon indicating copy to clipboard operation
qlib copied to clipboard

ValueError: The name datetime occurs multiple times, use a level number

Open Yuhang-Harry-Gao opened this issue 9 months ago • 4 comments

仅在workflow中将Alpha158改成Alpha360后,「prediction, backtest & analysis」环节出现ValueError: The name datetime occurs multiple times, use a level number

Yuhang-Harry-Gao avatar Mar 07 '25 03:03 Yuhang-Harry-Gao

Similar problem, when use: analysis_position.rank_label_graph(positions, label_df)

It was caused in line 171, qlib/contrib/report/analysis_position/parse_position.py

_position_df = parse_position(position)

This generate dataframe with multiindex ['instruments','datetime']

if calculate_label_rank:
    _position_df = _calculate_label_rank(_position_df)

Dataframe transfer to multiindex ['datetime','instruments','datetime'] , and caused the above error

Droplevel could fix it: _position_df = _position_df.droplevel(level=0, )

EnjoyLeole avatar Mar 16 '25 04:03 EnjoyLeole

Hi, @Yuhang-Harry-Gao @EnjoyLeole I'd like to know how to reproduce the problem.

SunsetWolf avatar Apr 27 '25 07:04 SunsetWolf

This issue is likely caused by the ProcessInf Processor, and it is very likely related to how the datetime_groupby_apply function processes the data. My dataset does not contain any Infinity values, but after applying this Processor, an additional column for datetime appears.

changjiang1203 avatar Apr 28 '25 10:04 changjiang1203

This issue is likely caused by the ProcessInf Processor, and it is very likely related to how the datetime_groupby_apply function processes the data. My dataset does not contain any Infinity values, but after applying this Processor, an additional column for datetime appears.

I think you're right, will this PR solve your problem?

SunsetWolf avatar Apr 29 '25 03:04 SunsetWolf