Add most functions to the Expr class so that they're chainable.
還沒有人認領這個 Issue。
評估
研究方向
從 Expr 類別和 issue 中參照的 functions 模組開始,然後比較現有的 Expr 方法與將表達式作為輸入的函式。為適用的函式新增可鏈式呼叫的方法,同時保留 functions 模組 API;完成後,所示的 col("id1").abs().alias("id1") 模式和多輸入範例應能正常運作。
由索引模型根據 Issue 內容生成。
描述
Is your feature request related to a problem or challenge? Please describe what you are trying to do.
Instead of doing
df.select(
F.abs(
col("id1")
)
.alias("id1")
)
It would be nicer to do
df.select(
col("id1")
.abs()
.alias("id1")
)
Describe the solution you'd like
This is already partly there, for example, alias is already in the Expr class. It would be a bit tedious but easy to add under class Expr, for example:
def abs(self) -> datafusion.Expr:
"""Return the absolute value of a given number.
Returns:
--------
Expr
A new expression representing the absolute value of the input expression.
"""
return F.abs(self)
Describe alternatives you've considered
if it weren't for the type hinter, monkey patching.
Additional context
There will still be functions that don't make sense to chain off of a call to col such as when since it doesn't return an Expr. But, even functions that take multiple inputs can have this for instance col("a").atan2("b"). Additionally, this is completely backwards compatible since I'm not proposing eliminating the functions module.
- 主要語言
- Python
- 星號
- 605
- 分支
- 176
- 平均合併
- 1 天 23 小時
- 30 天內合併 PR
- 8
貢獻指南
這個儲存庫沒有索引到貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
apache/datafusion-python 的其他 Issue
-
enhancement
難度 2/5 1-3 小時 新手友好度 70/100
apache/datafusion-python#1757 ·
-
documentation
難度 2/5 1-3 小時 新手友好度 72/100
apache/datafusion-python#1726 ·
-
難度 2/5 半天 新手友好度 88/100
apache/datafusion-python#1691 ·
-
bug
難度 2/5 1-3 小時 新手友好度 78/100
apache/datafusion-python#1644 ·
-
enhancement
難度 5/5 一週以上 新手友好度 30/100
apache/datafusion-python#1737 ·
查看 apache/datafusion-python 的全部 Issue
相似的 Issue
-
essnmx good first issue
難度 1/5 1 小時以內 新手友好度 95/100
-
難度 2/5 1-3 小時 新手友好度 65/100
syfoud/Simulated_Scepter#174 ·
-
難度 2/5 1-3 小時 新手友好度 75/100
Giskard-AI/giskard-oss#2840 · 1 則留言 ·
-
A claim comment carrying the issue number is silently declined while the workflow reports success 未關閉area: repo bug perceived difficulty: 2
難度 2/5 1-3 小時 新手友好度 70/100
-
難度 2/5 1-3 小時 新手友好度 75/100
yeti-platform/yeti#1380 ·