Skip to content

Fixed KeyMap issue with pandas 3.0.0: issue #1329#1330

Merged
VisLab merged 2 commits into
hed-standard:mainfrom
VisLab:fix_links
Jun 16, 2026
Merged

Fixed KeyMap issue with pandas 3.0.0: issue #1329#1330
VisLab merged 2 commits into
hed-standard:mainfrom
VisLab:fix_links

Conversation

@VisLab

@VisLab VisLab commented Jun 16, 2026

Copy link
Copy Markdown
Member

Fixed issue #1329

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses issue #1329 where KeyMap._remap() fails on pandas 3.0.x by adjusting how the internal mapping Series is constructed, and it expands unit test coverage to include numeric-key remapping scenarios that were previously problematic.

Changes:

  • Updated KeyMap._remap() to construct the mapping pd.Series with explicit data and index for pandas 3.0+ compatibility.
  • Added multiple new KeyMap.remap() unit tests covering numeric keys, stringified numeric keys, n/a values, and multi-key cascading cases.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

File Description
hed/tools/analysis/key_map.py Builds the mapping Series using explicit data/index to avoid pandas 3.0.x construction behavior.
tests/tools/analysis/test_key_map.py Adds regression tests for numeric-key and multi-key remapping scenarios tied to issue #1329.

Comment thread hed/tools/analysis/key_map.py
Comment thread tests/tools/analysis/test_key_map.py Outdated
Comment thread tests/tools/analysis/test_key_map.py Outdated
Comment thread tests/tools/analysis/test_key_map.py Outdated
Comment on lines +262 to +269
df_result, missing = key_map.remap(test_df)

self.assertEqual(len(df_result), 6, "remap should preserve number of rows")
self.assertEqual(df_result.iloc[0]['result'], 'correct_left')
self.assertEqual(df_result.iloc[1]['result'], 'correct_right')
# Rows with missing key combinations should get 'n/a'
self.assertEqual(df_result.iloc[2]['result'], 'n/a')
self.assertEqual(df_result.iloc[3]['result'], 'n/a')
Comment thread tests/tools/analysis/test_key_map.py Outdated
Comment thread tests/tools/analysis/test_key_map.py Outdated
@VisLab VisLab merged commit a59fb4c into hed-standard:main Jun 16, 2026
18 checks passed
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.

2 participants