Skip to content

Fix PortAnaRecord crash on duplicate "datetime" level (#1909)#2216

Open
genisis0x wants to merge 1 commit into
microsoft:mainfrom
genisis0x:fix/1909-datetime-multiple-levels
Open

Fix PortAnaRecord crash on duplicate "datetime" level (#1909)#2216
genisis0x wants to merge 1 commit into
microsoft:mainfrom
genisis0x:fix/1909-datetime-multiple-levels

Conversation

@genisis0x
Copy link
Copy Markdown

Summary

  • PortAnaRecord._generate and MultiPassPortAnaRecord.random_init resolved the prediction DataFrame's datetime level by name via index.get_level_values(\"datetime\").
  • Some handler/processor chains produce a MultiIndex that carries two levels both named datetime. In that case pandas raises ValueError: 'datetime' occurs multiple times, which is the crash in datetime occurs multiple times #1909.
  • Switch both call sites to positional lookup: dt_level = index.names.index(\"datetime\") then index.get_level_values(dt_level). That returns the first datetime level deterministically and survives duplicate names.

Test plan

  • New tests/misc/test_record_temp_duplicate_datetime.py builds a MultiIndex with duplicate datetime names and asserts:
    • name-based lookup raises ValueError (precondition)
    • positional lookup returns the expected values
  • Existing record-temp unit tests still pass (no behavior change on single-datetime indexes)

Fixes #1909

When the prediction DataFrame's MultiIndex carries two levels both named
"datetime" (which can happen with some handler/processor chains), pandas
raises "datetime occurs multiple times" on the name-based lookup. Resolve
the level positionally instead via index.names.index("datetime").

Same fix applied to MultiPassPortAnaRecord.random_init.

Fixes microsoft#1909
@genisis0x
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

datetime occurs multiple times

1 participant