timsaucer commented on code in PR #1481:
URL:
https://github.com/apache/datafusion-python/pull/1481#discussion_r3054078779
##########
docs/source/user-guide/common-operations/windows.rst:
##########
@@ -189,10 +186,14 @@ power in its ``"Type 1"`` using the
:py:func:`datafusion.functions.avg` function
col('"Name"'),
col('"Attack"'),
col('"Type 1"'),
- f.window("avg", [col('"Attack"')])
- .partition_by(col('"Type 1"'))
- .build()
- .alias("Average Attack"),
+ f.avg(col('"Attack"')).over(
+ Window(
+ window_frame=WindowFrame("rows", None, None),
+ partition_by=[col('"Type 1"')],
+ order_by=[col('"Speed"')],
+ null_treatment=NullTreatment.IGNORE_NULLS,
+ )
+ ).alias("Average Attack"),
Review Comment:
The window_frame is necessary so that we get the same avg across the entire
partition. Otherwise we'd need a sort on it afterwards to make sure it shows up
in the "running avg" and I think using the frame is more easy to understand.
But you're right about the null treatment and order_by.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]