pandas 3.0: three remaining set_index(<str column>.values) calls still raise TypeError (custom-labels paths)
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 82/100
Hướng nghiên cứu
Đọc ba vị trí gọi set_index trong wfdb/io/annotation.py, quanh label_triplets_to_df, set_custom_labels và get_contained_labels. Tái hiện lỗi với pandas 2.2.3 bằng cách dùng pd.set_option("future.infer_string", True) và kiểm tra các đường xử lý nhãn tùy chỉnh. Hoàn thành khi cả ba đường xử lý đều hoạt động mà không gặp TypeError đã báo cáo trong ngữ nghĩa chuỗi của pandas.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.)
- Ngôn ngữ chính
- Jupyter Notebook
- Star
- 853
- Fork
- 324
- Merge trung bình
- 17 giờ 39 phút
- Pull request đã merge (30 ngày)
- 10
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của MIT-LCP/wfdb-python
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 83/100
MIT-LCP/wfdb-python#594 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
MIT-LCP/wfdb-python#590 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
`find_local_peaks` ignores the sample at `i + radius`, so points on a rising slope are returned as peaksCó thể đã có người làm @rmz-oz đã nhận 27 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
MIT-LCP/wfdb-python#572 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
MIT-LCP/wfdb-python#595 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 67/100
MIT-LCP/wfdb-python#593 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của MIT-LCP/wfdb-python
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 84/100
wp-graphql/wp-graphql-woocommerce#1026 ·
-
bug integrator
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
grafana/sigma-rule-deployment#431 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
datamodel-code-generator/datamodel-code-generator#5587 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Shell: serve the home app's Cookie Policy on a hard reloadCó thể đã có người làm @2001anshkaushik đã nhận hôm nay. Đang mởfeature module:ai
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
rocketride-org/rocketride-server#2899 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày