Dataframe namespaces
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
- 20/100
Hướng nghiên cứu
Không có tệp, bài kiểm thử hoặc điểm vào triển khai nào được nêu. Hãy bắt đầu bằng việc xem xét namespace proposal, phần thảo luận trong #10 và phần thảo luận được liên kết trong issue #11; công việc được xem là hoàn tất khi đạt được sự đồng thuận về một dataframe API tiêu chuẩn và extension model.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
In #10, it's been discussed that it would be convenient if the dataframe API allows method chaining. For example:
import pandas
(pandas.read_csv('countries.csv')
.rename(columns={'name': 'country'})
.assign(area_km2=lambda df: df['area_m2'].astype(float) / 100)
.query('(continent.str.lower() != "antarctica") | (population < area_km2)'))
This implies that most functionality is implemented as methods of the dataframe class. Based on pandas, the number of methods can be 300 or more, so it may be problematic to implement everything in the same namespace. pandas uses a mixed approach, with different techniques to try to organize the API.
Approaches
Top-level methods
df.sum()
df.astype()
Many of the methods are simply implemented directly as methods of dataframe.
Prefixed methods
df.to_csv()
df.to_parquet()
Some of the methods are grouped with a common prefix.
Accessors
df.str.lower()
df.dt.hour()
Accessors are a property of dataframe (or series, but assuming only one dataframe class for simplicity) that groups some methods under it.
Functions
pandas.wide_to_long(df)
pandas.melt(df)
In some cases, functions are used instead of methods.
Functional API
df.apply(func)
df.applymap(func)
pandas also provides a more functional API, where functions can be passed as parameters
Standard API
I guess we will agree, that a uniform and consistent API would be better for the standard. That should make things easier to implement, and also a more intuitive experience for the user.
Also, I think it would be good that the API can be extended easily. Couple of example of how pandas can be extended with custom functions:
@pd.api.extensions.register_dataframe_accessor('my_accessor')
class MyAccessor:
def my_custom_method(self):
return True
df.my_accessor.my_custom_method()
df.apply(my_custom_function)
df.apply(numpy.sum)
Conceptually, I think there are some methods that should go together, more than by topic, by the API they follow. The clearest example is reductions, and there was some discussion in https://github.com/pydata-apis/dataframe-api/issues/11#issuecomment-644115670.
I think no solution will be perfect, and the options that we have are (feel free to add to the list if I'm missing any option worth considering):
Top-level methods
df.sum()
Prefixed methods
df.reduce_sum()
Accessors
df.reduce.sum()
Functions
mod.reductions.sum(df)
mod represents the implementation module (e.g. pandas)
Functional API
df.reduce(mod.reductions.sum)
Personally, my preference is the functional API. I think it's the simplest that keeps things organized, and the simplest to extend. The main drawback is its readability, it may be too verbose. There is the option to allow using a string instead of the function for known functions (e.g. df.reduce('sum')).
Thoughts? Other ideas?
- 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ự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
task
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
danparshall/claude_researcher#87 ·
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 85/100
datajoint/datajoint-python#1586 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
1D intercept of length 1 is accepted as `fix_params` in population GLM with more than 1 unitCó thể đã có người làm @dhvani7014 đã nhận hôm nay. Đang mởbug good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
flatironinstitute/nemos#642 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Broken links in the docsĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
uniswap-python/uniswap-python#487 ·