Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

pandas 3.0: three remaining set_index(<str column>.values) calls still raise TypeError (custom-labels paths)

Offen Anfängerfreundlich
#574 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@wenh06 arbeitet bereits daran.

Seit 23.10.2026.

  • #575 von @wenh06 — offen

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
82/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
pandas, python
Bereich
backend

Rechercherichtung

Lies die drei Aufrufstellen von set_index in wfdb/io/annotation.py im Umfeld von label_triplets_to_df, set_custom_labels und get_contained_labels. Reproduziere den Fehler mit pandas 2.2.3 unter Verwendung von pd.set_option("future.infer_string", True) und teste die Pfade für benutzerdefinierte Labels. Die Aufgabe ist abgeschlossen, wenn alle drei Pfade ohne den gemeldeten TypeError unter der String-Semantik von pandas funktionieren.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Description

#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:

  • line ~728 (label_triplets_to_df region):
    custom_labels.set_index(custom_labels["label_store"].values, inplace=True)
    
  • line ~1325 (set_custom_labels / DataFrame custom_labels path):
    self.custom_labels.set_index(self.custom_labels["label_store"].values, inplace=True)
    
  • line ~1347 (get_contained_labels region):
    label_map.set_index(label_map["symbol"].values, inplace=True)
    

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

import pandas as pd
pd.set_option("future.infer_string", True)
import wfdb
from wfdb.io.annotation import Annotation
# 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):

custom_labels.set_index("label_store", inplace=True)
self.custom_labels.set_index("label_store", inplace=True)
label_map.set_index("symbol", inplace=True)

Happy to open a PR with these three one-line changes if useful.

(Context: downstream ECG libraries, e.g. DeepPSP/torch_ecg, still pin pandas < 3 partly on this; a fix would help unblock the pandas-3 migration.)

Vorherrschende Sprache
Jupyter Notebook
Sterne
853
Forks
324
Ø Merge
17 Std. 39 Min.
Gemergte PRs (30 T.)
10

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus MIT-LCP/wfdb-python

Alle Issues in MIT-LCP/wfdb-python

Ähnliche Issues

Weitere Issues zu Backend & API Design

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.