Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Yuhang-Harry-Gao opened this issue Mar 7, 2025 · 4 comments
Labels
question Further information is requested

Comments

@Yuhang-Harry-Gao
Copy link

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

@Yuhang-Harry-Gao Yuhang-Harry-Gao added the question Further information is requested label Mar 7, 2025
@EnjoyLeole
Copy link

EnjoyLeole commented Mar 16, 2025

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, )

csh589 pushed a commit to csh589/qlib that referenced this issue Mar 21, 2025
- adapt pandas >= 1.5.0
- add group_keys when the result from apply is a like-indexed Series or DataFrame
csh589 added a commit to csh589/qlib that referenced this issue Mar 21, 2025
- adapt pandas >= 1.5.0
- add group_keys when the result from apply is a like-indexed Series or DataFrame
@SunsetWolf
Copy link
Collaborator

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

@changjiang1203
Copy link

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.

@SunsetWolf
Copy link
Collaborator

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants