File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed
docs/source/user-guide/common-operations Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -175,10 +175,7 @@ it's ``Type 2`` column that are null.
175175 Aggregate Functions
176176-------------------
177177
178- You can use any :ref: `Aggregation Function<aggregation> ` as a window function. Currently
179- aggregate functions must use the deprecated
180- :py:func: `datafusion.functions.window ` API but this should be resolved in
181- DataFusion 42.0 (`Issue Link <https://github.com/apache/datafusion-python/issues/833 >`_). Here
178+ You can use any :ref: `Aggregation Function<aggregation> ` as a window function. Here
182179is an example that shows how to compare each pokemons’s attack power with the average attack
183180power in its ``"Type 1" `` using the :py:func: `datafusion.functions.avg ` function.
184181
@@ -189,10 +186,14 @@ power in its ``"Type 1"`` using the :py:func:`datafusion.functions.avg` function
189186 col(' "Name"' ),
190187 col(' "Attack"' ),
191188 col(' "Type 1"' ),
192- f.window(" avg" , [col(' "Attack"' )])
193- .partition_by(col(' "Type 1"' ))
194- .build()
195- .alias(" Average Attack" ),
189+ f.avg(col(' "Attack"' )).over(
190+ Window(
191+ window_frame = WindowFrame(" rows" , None , None ),
192+ partition_by = [col(' "Type 1"' )],
193+ order_by = [col(' "Speed"' )],
194+ null_treatment = NullTreatment.IGNORE_NULLS ,
195+ )
196+ ).alias(" Average Attack" ),
196197 )
197198
198199 Available Functions
You can’t perform that action at this time.
0 commit comments