1515.. specific language governing permissions and limitations
1616.. under the License.
1717
18+ .. _window_functions :
19+
1820Window Functions
1921================
2022
21- In this section you will learn about window functions. A window function utilizes values from one or multiple rows to
22- produce a result for each individual row, unlike an aggregate function that provides a single value for multiple rows.
23+ In this section you will learn about window functions. A window function utilizes values from one or
24+ multiple rows to produce a result for each individual row, unlike an aggregate function that
25+ provides a single value for multiple rows.
2326
24- The functionality of window functions in DataFusion is supported by the dedicated :py:func : `~datafusion.functions.window ` function .
27+ The window functions are availble in the :py:mod : `~datafusion.functions ` module .
2528
2629We'll use the pokemon dataset (from Ritchie Vink) in the following examples.
2730
@@ -40,17 +43,18 @@ We'll use the pokemon dataset (from Ritchie Vink) in the following examples.
4043 ctx = SessionContext()
4144 df = ctx.read_csv(" pokemon.csv" )
4245
43- Here is an example that shows how to compare each pokemons’s attack power with the average attack power in its ``"Type 1" ``
46+ Here is an example that shows how to compare each pokemons’s attack power with the average attack
47+ power in its ``"Type 1" ``
4448
4549.. ipython :: python
4650
4751 df.select(
4852 col(' "Name"' ),
4953 col(' "Attack"' ),
50- f.alias(
51- f.window(" avg" , [col(' "Attack"' )], partition_by = [col(' "Type 1"' )]),
52- " Average Attack" ,
53- )
54+ # f.alias(
55+ # f.window("avg", [col('"Attack"')], partition_by=[col('"Type 1"')]),
56+ # "Average Attack",
57+ # )
5458 )
5559
5660 You can also control the order in which rows are processed by window functions by providing
@@ -61,15 +65,15 @@ a list of ``order_by`` functions for the ``order_by`` parameter.
6165 df.select(
6266 col(' "Name"' ),
6367 col(' "Attack"' ),
64- f.alias(
65- f.window(
66- " rank" ,
67- [],
68- partition_by = [col(' "Type 1"' )],
69- order_by = [f.order_by(col(' "Attack"' ))],
70- ),
71- " rank" ,
72- ),
68+ # f.alias(
69+ # f.window(
70+ # "rank",
71+ # [],
72+ # partition_by=[col('"Type 1"')],
73+ # order_by=[f.order_by(col('"Attack"'))],
74+ # ),
75+ # "rank",
76+ # ),
7377 )
7478
7579 The possible window functions are:
0 commit comments