Calling methods on invalid types
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 25/100
Hướng nghiên cứu
Bắt đầu bằng cách đọc cuộc thảo luận được liên kết, issue #11 và issue #6, sau đó so sánh các trường hợp reduction của DataFrame và Series được nêu. Issue không chỉ rõ các tệp triển khai hoặc các bài kiểm thử; để hoàn thành sẽ cần có chính sách được thống nhất cho các Dtypes không hợp lệ và hành vi nhất quán giữa các thao tác.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
This is a follow up of the discussions in:
- https://github.com/pydata-apis/dataframe-api/issues/6#issuecomment-639754182
- #11 (question:
pandas has parameters (bool_only, numeric_only) to let only apply the operation over columns of certain types only. Do we want it?)
See this example:
>>> df[['name', 'population']].mean()
population 2.729748e+07
dtype: float64
Even if the name column is selected, it is being ignored, since the mean of a string columns does not make sense. As opposed to raising an exception.
Many reductions implement a parameter to let control this behavior:
df[['name', 'population']].mean(numeric_only=False)
TypeError: could not convert string to float:
If we consider more methods to be applied directly over a dataframe, for example:
>>> df[['first_'name', 'last_name']].str.lower()
We may end up with a huge amount of string_only, bool_only, numeric_only parameters. All meaning something similar, but IMO adding a decent amount of complexity, and being difficult to keep the behavior consistent.
My preference would be to always raise, but being a software engineer I'm biased, and I guess many users may want this "magic".
So, I guess implementing an option, for example: pandas.options.mode.invalid_dtype {raise or skip} could make more sense.
The main problem with this approach is probably that it's not as easy to define the behavior for each operation:
(df.mean(numeric_only=True)
.mean(numeric_only=False))
Personally, I don't see this as an issue. IMO, the behavior depends more on the user than on the operation. I'd say for production code, having to be explicit, and selecting the columns to operate with, makes more sense. While in a notebook, avoiding exceptions with this sort of "magic" seems to be more useful.
I guess for Series/1-column DataFrame (see #6) it always makes sense to raise an exception.
Thoughts?
- Ngôn ngữ chính
- Python
- Star
- 106
- Fork
- 22
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
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 data-apis/dataframe-api
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
data-apis/dataframe-api#363 · 1 bình luận · 8 reaction ·
-
Row ordering design choiceĐang mởAPI design
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
data-apis/dataframe-api#356 · 1 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
data-apis/dataframe-api#355 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
data-apis/dataframe-api#352 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
data-apis/dataframe-api#351 ·
Tất cả issue của data-apis/dataframe-api
Issue tương tự
-
customer-reported question
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Azure/azure-sdk-for-python#49548 · 1 bình luận · 1 reaction ·
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 88/100
btclib-org/btclib-wallet#409 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Phase 2 PSA Capability & Career Profile
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
bcgov/digital-journeys#2310 ·
-
bug good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
fastmachinelearning/hls4ml#1582 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Sort modelsĐang mởenhancement good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày