From f3f09470115b3d7f6e6a4bb2e89766e236fff5b3 Mon Sep 17 00:00:00 2001 From: WEN Hao Date: Sat, 24 Oct 2026 00:26:53 +0800 Subject: [PATCH] Fix pandas-3 crash in get_contained_labels: set_index on string .values set_index(series.values) rejects the ArrowStringArrayNumpySemantics that Series.values returns for string columns under pandas' new string dtype (pandas 3.0, or pandas 2.x with future.infer_string). get_contained_labels hits this via the symbol (and description) columns. Pass the column labels instead, which is equivalent on every pandas version. Follow-up to #561, which wrapped the module-level ann_class_table call in pd.Index but left the string-column sites in get_contained_labels. Fixes #574. --- wfdb/io/annotation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wfdb/io/annotation.py b/wfdb/io/annotation.py index 1cbadf76..b81b9627 100644 --- a/wfdb/io/annotation.py +++ b/wfdb/io/annotation.py @@ -1344,12 +1344,12 @@ def get_contained_labels(self, inplace=True): counts = np.unique(self.label_store, return_counts=True) elif self.symbol is not None: index_vals = set(self.symbol) - label_map.set_index(label_map["symbol"].values, inplace=True) + label_map.set_index("symbol", inplace=True) reset_index = True counts = np.unique(self.symbol, return_counts=True) elif self.description is not None: index_vals = set(self.description) - label_map.set_index(label_map["description"].values, inplace=True) + label_map.set_index("description", inplace=True) reset_index = True counts = np.unique(self.description, return_counts=True) else: