fix: record_temp datetime extraction with ambiguous level names#2173
Open
EdenRochmanSharabi wants to merge 1 commit intomicrosoft:mainfrom
Open
fix: record_temp datetime extraction with ambiguous level names#2173EdenRochmanSharabi wants to merge 1 commit intomicrosoft:mainfrom
EdenRochmanSharabi wants to merge 1 commit intomicrosoft:mainfrom
Conversation
PortAnaRecord._generate and MultiPassPortAnaRecord.random_init used
pred.index.get_level_values("datetime") which assumes datetime is a
named level that pandas can resolve directly. This can fail when the
MultiIndex level ordering differs. Now we first resolve the position
with index.names.index("datetime") and pass the integer position to
get_level_values().
Fixes microsoft#1909
Author
|
@microsoft-github-policy-service agree |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1909
pred.index.get_level_values("datetime")fails when the datetime level position varies in the MultiIndex. The string-based lookup is ambiguous when level ordering differs from what is assumed.Changes
qlib/workflow/record_temp.py: Replaced string-basedget_level_values("datetime")with positional lookup viaindex.names.index("datetime")in bothPortAnaRecord._generate()andMultiPassPortAnaRecord.random_init()tests/test_record_temp_datetime.py: Tests covering datetime at different positions and missing datetime level