You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
pandas 3.0: three remaining set_index(<str column>.values) calls still raise TypeError (custom-labels paths) #574
#561 (v4.3.1) fixed the module-level ann_class_table.set_index(...) that crashed import wfdb under pandas 3 string semantics — thank you! However, three sibling patterns remain in wfdb/io/annotation.py (checked on main and in the v4.3.1 sdist), all passing a string column's.values directly as set_index keys:
With pandas' new string dtype (pandas 3.0, or 2.x with pd.set_option("future.infer_string", True)), Series.values is an ArrowStringArrayNumpySemantics, which DataFrame.set_index rejects:
TypeError: The parameter "keys" may be a column key, one-dimensional array, or a list containing only valid column keys and one-dimensional arrays.
These are runtime paths (annotation objects with custom labels), so import wfdb now succeeds, but the custom-label functionality still breaks once pandas 3 is the default.
Reproduce
importpandasaspdpd.set_option("future.infer_string", True)
importwfdbfromwfdb.io.annotationimportAnnotation# any path that reaches set_custom_labels / label_triplets_to_df with a# DataFrame of custom labels -> TypeError above
(Versions: pandas 2.2.3 with the option / pandas 3.0; wfdb 4.3.1 and current main.)
Suggested fix
Pass the column label instead of the array — identical semantics on every pandas version (the keys are the column's values either way):
Correction after a closer look (and a pandas sandbox check): of the .values sites listed above, only the string columns actually raise — label_map["symbol"] (~1347) and label_map["description"] (~1352) in get_contained_labels. The label_store columns (~728, ~1325, ~1368, ~1518, and the module-level ~3232) are integer columns whose .values remains a plain numpy array and passes set_index today. Opened #575 with the minimal fix for the two breaking sites.
Activity
wenh06 commentedon Oct 23, 2026
Correction after a closer look (and a pandas sandbox check): of the
.valuessites listed above, only the string columns actually raise —label_map["symbol"](~1347) andlabel_map["description"](~1352) inget_contained_labels. Thelabel_storecolumns (~728, ~1325, ~1368, ~1518, and the module-level ~3232) are integer columns whose.valuesremains a plain numpy array and passesset_indextoday. Opened #575 with the minimal fix for the two breaking sites.