Dataframe namespaces
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 20/100
調査の方向性
ファイル、テスト、または実装のエントリーポイントは指定されていません。まず namespace proposal、#10 の議論、および issue #11 にリンクされた議論を確認してください。完了条件は、標準の dataframe API と extension model について合意することです。
索引モデルが issue の本文から書いたものです。
説明
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?
- 主要言語
- Python
- スター
- 106
- フォーク
- 22
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
data-apis/dataframe-api のほかの issue
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
data-apis/dataframe-api#363 · コメント 1 件 · リアクション 8 件 ·
-
API design
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
data-apis/dataframe-api#356 · コメント 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
data-apis/dataframe-api#355 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
data-apis/dataframe-api#352 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
data-apis/dataframe-api#351 ·
data-apis/dataframe-api の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 60/100
521xueweihan/HelloGitHub#3924 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
wilbowes/EchoMuse#869 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
-
namespace operations
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
EclipseFdn/open-vsx.org#14043 ·
メンテナーはふだん 1 日以内に返信
-
test: TestServeUntilStale races the server's close against the client's sendall (BrokenPipeError under load)対応中かも @evoludigit が今日担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 89/100
メンテナーはふだん 1 日以内に返信