Skip to content

fix: convert custom Index to list in SingleData.to_series()#2114

Open
Ayush10 wants to merge 1 commit intomicrosoft:mainfrom
Ayush10:fix/issue-2020-index-data-to-series
Open

fix: convert custom Index to list in SingleData.to_series()#2114
Ayush10 wants to merge 1 commit intomicrosoft:mainfrom
Ayush10:fix/issue-2020-index-data-to-series

Conversation

@Ayush10
Copy link

@Ayush10 Ayush10 commented Jan 31, 2026

Summary

  • SingleData.to_series() passed a qlib.utils.index_data.Index object directly to pd.Series(), which raises TypeError since pandas does not recognize it as a valid index type
  • Fixed by calling .tolist() to convert to a plain list, consistent with how __repr__() already handles it on the next line
  • One-line fix in qlib/utils/index_data.py

Root Cause

The Index class in qlib/utils/index_data.py is a custom high-performance index wrapper. While it supports iteration and .tolist(), pandas pd.Series() constructor does not accept it as a valid index parameter. The __repr__ method (line 618) already uses .tolist() correctly, but to_series() (line 614) did not.

Test plan

  • Verified SingleData.to_series() returns a valid pd.Series with correct index
  • Verified __repr__ continues to work
  • Existing tests pass without modification

Fixes #2020

SingleData.to_series() passed a qlib Index object directly to
pd.Series(), which raises TypeError since pandas does not recognize
it as a valid index type. Use .tolist() to convert to a plain list
first, consistent with how __repr__ already handles it on line 618.

Fixes microsoft#2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant