Issue: KeyMap._remap() ValueError on pandas 3.0.3
KeyMap._remap() fails with ValueError: Length of values (2) does not match length of index (0) on pandas 3.0.3
Exact Reproduction Case
Input Data
import pandas as pd
# Test DataFrame - exactly as used in test_numeric_keys_cascade
df = pd.DataFrame({
'test': [1, 2, 'n/a', 3, 4, 5],
'response_accuracy': ['correct', 'correct', 'correct', 'n/a', 'correct', 'correct'],
'response_hand': ['right', 'right', 'right', 'n/a', 'left', 'left']
})
print("Input DataFrame:")
print(df)
print("\nDataFrame dtypes:")
print(df.dtypes)
print("\nDataFrame shape:", df.shape)
Output:
Input DataFrame:
test response_accuracy response_hand
0 1 correct right
1 2 correct right
2 n/a correct right
3 3 n/a n/a
4 4 correct left
5 5 correct left
DataFrame dtypes:
test object
response_accuracy object
response_hand object
dtype: object
DataFrame shape: (6, 3)
Operation Configuration
from hed.tools.analysis.key_map import KeyMap
# Remap configuration - cascading numeric keys
# Maps: 1→"correct_left", 2→"correct_right" for test column
map_list = [
[1, 1, "correct_left"], # When test=1 AND response_accuracy=1, create "correct_left"
[2, 2, "correct_right"] # When test=2 AND response_accuracy=2, create "correct_right"
]
key_map = KeyMap(
source_columns=['test'],
map_list=map_list
)
# This is where it fails
df_remapped, missing = key_map.remap(df)
Exact Error
On pandas 3.0.3 (FAILS):
ValueError: Length of values (2) does not match length of index (0)
Issue:
KeyMap._remap()ValueError on pandas 3.0.3KeyMap._remap()fails withValueError: Length of values (2) does not match length of index (0)on pandas 3.0.3Exact Reproduction Case
Input Data
Output:
Operation Configuration
Exact Error
On pandas 3.0.3 (FAILS):