pandas 3.0: three remaining set_index(<str column>.values) calls still raise TypeError (custom-labels paths)
Mantenedores costumam responder em até 1 dia
Avaliação
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Facilidade para iniciantes
- 82/100
Direção de pesquisa
Leia os três pontos de chamada de set_index em wfdb/io/annotation.py, próximos a label_triplets_to_df, set_custom_labels e get_contained_labels. Reproduza o problema com pandas 2.2.3 usando pd.set_option("future.infer_string", True) e exercite os caminhos de rótulos personalizados. O trabalho estará concluído quando os três caminhos funcionarem sem o TypeError relatado sob a semântica de strings do pandas.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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_dfregion):custom_labels.set_index(custom_labels["label_store"].values, inplace=True) - line ~1325 (
set_custom_labels/ DataFramecustom_labelspath):self.custom_labels.set_index(self.custom_labels["label_store"].values, inplace=True) - line ~1347 (
get_contained_labelsregion):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.)
- Linguagem predominante
- Jupyter Notebook
- Estrelas
- 853
- Forks
- 324
- Merge médio
- 17h 39min
- PRs com merge (30d)
- 10
Preparar o ambiente
Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de MIT-LCP/wfdb-python
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 72/100
MIT-LCP/wfdb-python#590 ·
Mantenedores costumam responder em até 1 dia
-
`find_local_peaks` ignores the sample at `i + radius`, so points on a rising slope are returned as peaksTalvez já em andamento @rmz-oz assumiu há 27 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
MIT-LCP/wfdb-python#572 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 45/100
MIT-LCP/wfdb-python#568 ·
Mantenedores costumam responder em até 1 dia
-
Add validation of segments when writing a `MultiRecord`Talvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Aberta
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 48/100
MIT-LCP/wfdb-python#557 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 58/100
MIT-LCP/wfdb-python#554 ·
Mantenedores costumam responder em até 1 dia
Todas as issues de MIT-LCP/wfdb-python
Issues semelhantes
-
bug review needed
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 86/100
OpenMage/magento-lts#5816 ·
Mantenedores costumam responder em até 2 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
libsdl-org/SDL#16607 ·
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
swc-project/swc-next#1165 ·
Mantenedores costumam responder em até 1 dia
-
app: scripts severity: low status: backlog type: bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
netbox-community/netbox-scripts#64 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 73/100
Alive24/shea-symphony#574 ·